Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 1.64 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Jquery and webserver controls
  2. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestForm.aspx.cs"     Inherits="TestForm" %>
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <title></title>
  7.   <script src="http://code.jquery.com/jquery-1.5.js" type="text/jscript"></script>
  8. </head>
  9. <body>
  10.  
  11.   <p>Hello</p>
  12.   <a href="#">Click to hide me too</a>
  13.   <p>Here is another paragraph</p>
  14.   <input id="HTMLButton" type="button" value="HTML Button"  />
  15.  
  16. <script type="text/jscript" >
  17.   //Desired Behavior. The Command button outside Form Attribute works are desired.
  18.   $("input").click(function () {
  19.     $("#NameText").toggle()
  20.   });
  21.  
  22.   $("#<%=WebCtrlJScript.ClientID%>").click(function () {
  23.     alert("Button btnToggleDiv from Name Clicked");
  24.     $("#NameText").toggle();
  25.   });
  26.  
  27.   //This is simple HTML button inside Form Element.
  28.   $("#HTMLInsideForm").click(function () {
  29.     alert("Button HTMLInsideForm Clicked");
  30.       $("#NameText").toggle()
  31.   });
  32.  
  33.  
  34. </script>
  35.  
  36. <script type="text/javascript">
  37.   function NameText() {
  38.     alert("WebCtrlOnClientClick Clicked");
  39.     $("#NameText").hide();
  40.     this.blur();
  41.   }
  42.  
  43. </script>
  44. <form id="Form1" runat="server">
  45. <div id="NameText">
  46.   <table>
  47.     <tr>
  48.       <td>
  49.         <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
  50.       </td>
  51.       <td>
  52.         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  53.       </td>
  54.     </tr>
  55.   </table>
  56. </div>
  57. <div>
  58.   <asp:Button ID="WebCtrlOnClientClick" runat="server" Text=".Net Button" OnClientClick="NameText()"/>
  59.   <asp:Button ID="WebCtrlJScript" runat="server" Text="JScript Button"/>
  60.   <input id="HTMLInsideForm" type="button" value="HTML Button(Inside Div)" />
  61. </div>
  62. </form>
  63. </body>
  64. </html>