Sign in | Join
Last post 04-29-2008 1:01 PM by GregSQL. 5 replies.
Sort Posts: Oldest to newest Newest to oldest
How can I access the ItemNo variable from my code-behind? I've tried assigning it to the text of a textbox but I get an error that <% %> is not allowed for server controls.
<%
Response.Write(ItemNo)
%>
ItemNo.Text
This is a Web Control, it would not be accessed the same way as just a form element. :)
I'm trying to access the string in the HTML page (Dim ItemNo As String) from the code-behind. It says it isn't declared.
I know I can access the <asp:TextBox> from the code-behind, but what about the string or the <input> field?
This might not be the exact answer, but you can use a ViewState and set the QueryString to it, so you can retrieve it in the code behind. Or you could use a label instead of a string.
GridViewBoy: This might not be the exact answer, but you can use a ViewState and set the QueryString to it, so you can retrieve it in the code behind. Or you could use a label instead of a string.
Here is what I tried:
Response.Write(ItemNo2)
When I try to access the viewstate or session variable in the code-behind, I get an error as if the variable doesn't exist.
I was able to set a label in the HTML page using Label1.Text = ItemNo but when I test it, the value doesn't change. Same thing happens when I try to set a textbox. The value doesn't change.
<
ItemNo.Text = ItemNo2
Label1.Text = ItemNo2
The answer was to simply do this in the code-behind instead of the HTML
Sorry, I'm a doofus sometimes.