Click to See Complete Forum and Search --> : text box not declared


devilonline
02-13-2008, 10:09 PM
Hi. I'm trying to learn asp.net and i'm reading some tutorials.
well i've made an text box and i wanto to display some variable. but it says that the text box isn't declared. here is the code:
TextBox1.Text = strResult

thanks

Emefa
02-14-2008, 04:32 PM
Hi. I'm trying to learn asp.net and i'm reading some tutorials.
well i've made an text box and i wanto to display some variable. but it says that the text box isn't declared. here is the code:
TextBox1.Text = strResult

thanks


Can you post your entire code here?
That's the only way someone can help you out.

Hack
02-15-2008, 07:00 AM
Do you have a control on your form called TextBox1?

devilonline
02-17-2008, 01:58 PM
here is all code. thanks Imports System.IO
Imports System.Net
Partial Class Default1
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strURL As String = ""
Dim strPostData As String = ""
Dim strResult As String = ""
Dim wbrq As HttpWebRequest
Dim wbrs As HttpWebResponse
Dim sw As StreamWriter
Dim sr As StreamReader

' Set the URL to post to
strURL = "http://www.webcom.com/cgi-bin/form"
' Post some values to the page
strPostData = String.Format("your_name={0}&userid={1}&form_name={2}", "Mark Smith", "webcom", "tutortest")

' Create the web request
wbrq = WebRequest.Create(strURL)
wbrq.Method = "POST"
' We don't always need to set the Referer but in this case
' the page we are posting to will only issue a response if we do
wbrq.Referer = "http://www.webcom.com/cgi-bin/form"
wbrq.ContentLength = strPostData.Length
wbrq.ContentType = "application/x-www-form-urlencoded"

' Post the data
sw = New StreamWriter(wbrq.GetRequestStream)
sw.Write(strPostData)
sw.Close()

' Read the returned data
wbrs = wbrq.GetResponse
sr = New StreamReader(wbrs.GetResponseStream)
strResult = sr.ReadToEnd.Trim
sr.Close()

' Write the returned data out to the page
TextBox1.Text = strResult
End Sub
End Class

Emefa
02-21-2008, 02:14 PM
Make sure that on your .aspx page, you have your html setup as:
It is important to put the Textbox control inside a form that is configured to run at the server runtime, hence the runat ="server" tag

<html>
<body>
<form id ="form1" runat ="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
</body>
</html>

vasu84
02-22-2008, 11:03 AM
Hi... I'm also learning ASP.net now only..
Please try this out... I don have the software to test this code..

TextBox1.Text = strResult.ToString()