1

I have a hidden field that i want to bind to either a function on the page's code behind. I don't quite recall the exact syntax and i can't find the answer via Google. Is the code below correct? Thank.

print("<asp:HiddenField ID="dummy" Value='<%#Getdummy() %>' runat="server" />");
1
  • Is there a print function in asp.net? There are quotation marks inside the string with out escape sequence. Commented Dec 9, 2011 at 21:11

2 Answers 2

2

The code you've put looks pretty good ...

The two step process is ... add the hidden field to the markup

<asp:HiddenField ID="hdnId" runat="server" Value='<%# GetValue() %>'/>

Then create the specified method signature ...

protected string GetValue()
{
   return "something";
}

Hope this helps ...

Sign up to request clarification or add additional context in comments.

1 Comment

One thing I would like to add, DataBinding is not supported by MenuItem so this method can not be used to enable/disable a particular item in a menu.
0

If you have the hidden field with runat=server, you could write code to assign value in the code behind (rather than in the markup).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.