Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8425803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:22:25+00:00 2026-06-10T04:22:25+00:00

I have aspnet form, were jquery function is load: <script type=text/javascript> $(document).ready(function () {

  • 0

I have aspnet form, were jquery function is load:

<script type="text/javascript">
    $(document).ready(function () {
        var table = document.getElementById('<%=grdNews.ClientID%>');
        var tableDnD = new TableDnD();
        tableDnD.init(table);
    })
</script>

FYI: this is not my code and I haven’t developed TableDnD class. This clss attaches drag & drop functionality for one table in aspnet form.

Everything works fine here.

However, now I have a new requirement: for some users I do not need to do this jquery, for some – this jquery is still necessary. How can I achieve this programmatically? This would be something like:

ON PAGE LOAD:
if (User == SpecificUser) 
{
     ALLOW_ABOVE_JQUERY (LOAD JQUERY FUNCTION ON LOAD) //?HOW
}
else 
{
     DO_NOT_ALLOW_ABOVE_JQUERY (DISABLE LOADING JQUERY FUNCTION ON LOAD) //?HOW
}

It is something about javascript in code behind, but this is $(document).ready that makes me confused.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:22:27+00:00Added an answer on June 10, 2026 at 4:22 am

    You can use server tags in the markup:

    <% if (User == SpecificUser) { %>
    <script type="text/javascript">
      $(document).ready(function () {
        var table = document.getElementById('<%=grdNews.ClientID%>');
        var tableDnD = new TableDnD();
        tableDnD.init(table);
      });
    </script>
    <% } %>
    

    Alternatively you can put it in a place holder:

    <asp:PlaceHolder ID="ScriptContainer" runat="server">
    <script type="text/javascript">
      $(document).ready(function () {
        var table = document.getElementById('<%=grdNews.ClientID%>');
        var tableDnD = new TableDnD();
        tableDnD.init(table);
      });
    </script>
    </asp:PlaceHolder>
    

    Then hide the content from code behind:

    if (User != SpecificUser) {
      ScriptContainer.Visible = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form written below: <table> <tr> <td>Worker Type:</td> <td><input type=text id=WorkerTypeTB/></td> </tr>
I am trying to load a page in a div With jQuery : $(document).ready(function
A very strange problem, I have a text box in aspnet web form. I
I have created a great stand-alone web form in asp.net utilizing many jQuery features
I have an ASP.NET form with three text inputs, one each for Work Phone,
I have an jQuery accordion for a form on an internal company website. They
I have an asp.net form. I want to show a jquery progress image while
I'm using asp.net mvc 3 with unobtrusive jquery validation. I have a form that
I'm using MVC 3 with unobtrusive javascript for client validation. I have a table
I have an ASP.NET form (C#) but which I click this button that should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.