Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi all,

 

This is my code, which give me an error of "name" is not declared

 

'code for WebForm1.aspx.vb
Sub submit(ByVal sender As Object, ByVal e As EventArgs)
       If name.value <> "" Then
           p1.InnerHtml = "Welcome " & name.value & "!"
       End If
   End Sub

 

Code for WebForm1.aspx

 

 
<form runat="server">
Enter your name: <input id="name" type="text" size="30" runat="server" />
<br /><br />
<input type="submit" value="Submit" OnServerClick="submit" runat="server" />
<p id="p1" runat="server" />
</form>

The name is my input id, how to pass the value?

programing programer program
Posted

In order to reference a control, the code-behind must know about the control. In your case, the code-behind has no idea the control exists, probably because the control is not declared in your code-behind file.

 

If you're using VS 2003, you can switch to design view, and then switch back to HTML view. That should add the control.

 

Or, you could declare the control yourself.

 

Protected WithEvents name as HtmlInputText

Posted
In order to reference a control, the code-behind must know about the control. In your case, the code-behind has no idea the control exists, probably because the control is not declared in your code-behind file.

 

If you're using VS 2003, you can switch to design view, and then switch back to HTML view. That should add the control.

 

Or, you could declare the control yourself.

 

Protected WithEvents name as HtmlInputText

 

ok, thank you very much

programing programer program

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...