accessing C#/html objects from js

  • Thread starter Thread starter Jeff User
  • Start date Start date
J

Jeff User

hi all

Using C#, .NET1.1.

I need to pass a string of text to the final html output and then
capture it with java script on the client side. I found that I can
place my string in and then access a textbox or a label from the js,
but only if the textbox or label is visible. If they are hidden (and
then need to be) then they are not created in the html output.

I also think I could access a hidden html INPUT tag, but, I dont know
how to place my string of text in an html control from the C# code.

Anyideas how I can hide a string of text from my C# and then get it
using the js?

Thanks
Jeff
 
Jeff User said:
I need to pass a string of text to the final html output and then
capture it with java script on the client side. I found that I can
place my string in and then access a textbox or a label from the js,
but only if the textbox or label is visible. If they are hidden (and
then need to be) then they are not created in the html output.

I also think I could access a hidden html INPUT tag, but, I dont know
how to place my string of text in an html control from the C# code.

Anyideas how I can hide a string of text from my C# and then get it
using the js?

With a hidden field: Decare the field as <input type="hidden"
runat="server" id="hiddenField">. Then change its contents in C# as
hiddenField.Value="something";

Another alternative: inside your javascript code, assuming it is written
on the page itself and not in an included .js file, write a <%=variable%> in
the place where you need a value taken from the code-behind. In your
code-behind, declare "variable" as a public field or property.
 
Back
Top