miwaypro Posted February 10, 2006 Posted February 10, 2006 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? Quote programing programer program
sbauer Posted February 12, 2006 Posted February 12, 2006 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 Quote
miwaypro Posted February 13, 2006 Author Posted February 13, 2006 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 Quote programing programer program
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.