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

Untitled

By: a guest on Apr 18th, 2012  |  syntax: None  |  size: 0.90 KB  |  hits: 27  |  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. ASP.NET - Passing a C# variable to HTML [closed]
  2. <asp:TextBox ID="TextBoxChildID" Text='<%= Child_ID %>' runat="server" Enabled="false"></asp:TextBox>
  3.        
  4. <asp:TextBox ID="TextBoxChildID"  runat="server" Enabled="false"><%= Child_ID %></asp:TextBox>
  5.        
  6. <asp:TextBox ID="TextBoxChildID"  runat="server" Enabled="false"></asp:TextBox>
  7.        
  8. TextBoxChildID.Text = Child_ID;
  9.        
  10. '<%# Child_ID %>'
  11.        
  12. <script type="text/javascript">
  13.     function abc()
  14.     {
  15.         var id = document.getElementById('txtTextBox');
  16.         id.value=<%=MyProperty %>;
  17.         alert(id.value);
  18.     }
  19. </script>
  20.        
  21. protected int MyProperty
  22. {
  23.     get
  24.     {
  25.         return 1;
  26.     }
  27. }
  28.        
  29. Page.RegisterStartupScript(Guid.NewGuid().ToString(),
  30.  "<script language = 'javascript'>abc();</script>");
  31.        
  32. <asp:HiddenField ID="HiddenField1" runat="server" />
  33.        
  34. protected void Page_Load(object sender, EventArgs e)
  35. {
  36.     HiddenField1.Value = Child_ID;
  37. }