SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery transformations in ASP.net 4.0

    In jQuery in ASP.net 4.0:

    $("#TextBox1") becomes $("<%= TextBox1.ClientID %>")

    What does:

    $("#Button1") become ?

    $("#TextArea1") become ?

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Same thing (though you have a typo in your TextBox1 statement, you need the # sign still).

    Code:
    $("#<%= TextBox1.ClientID %>")
    $("#<%= Button1.ClientID %>")
    $("#<%= TextArea1.ClientID %>")
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do not think TextArea1 works the same it is a html control.

    $("#<%= TextArea1.ClientID %>") ?

    How do you do the opposite of:

    $("#<%= Button1.ClientID %>").click(function (e) {
    e.preventDefault();

    In other words how do you click Button1 programatically from jQuery?

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    You want to invoke the click or capture it?

    Capturing would be exactly how you showed it:
    Code:
    $("#<%= Button1.ClientID %>").click(function (e) {
    e.preventDefault(); });
    Invoking/Triggering it would be
    Code:
    $("#<%= Button1.ClientID %>").trigger('click');
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Philosophaie View Post
    I do not think TextArea1 works the same it is a html control.
    You know you can make one in .NET, using the asp:textbox and setting textmode to multiline and setting rows to the number of rows you want (makes it a textarea instead of a textbox).

    However, HtmlControls do have a ClientID property, so it should work regardless.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  6. #6
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does the following statement work with .NET 4.0, ASP.net 4.0 and jquery-1.4.1.js:

    $("#<%= Button1.ClientID %>").trigger('click');

  7. #7
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    It should. After all, it is just a button.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •