By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,276 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,276 IT Pros & Developers. It's quick & easy.

.text Property always empty on postback

P: n/a
Hi all,
i have a simple user control (domaincheck.ascx):

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="domaincheck.ascx.vb" Inherits="loopline_prod.bb.domaincheck"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<table>
<tr>
<td>
Domain name: <asp:TextBox id="txtDomain" runat="server" />
<asp:Button id="btnQuery" text="Query!" runat="server" />
<BR><HR width="100%"><BR>
<asp:label id="lblResult" runat="server" />
</td>
</tr>
</table>

and this code in my codebehind:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Page.IsPostBack Then
lblResult.Text = "Test: " & txtDomain.Text
End If
End Sub

the enclosing index.aspx, where the domaincheck.ascx is loaded, has a form
tag like this:
<form runat="server></form>

Thx in advance.
Regards Benjamin
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Check the client side HTML. Do you have a name an/or id for the form ? Also
it may requires perhaps the "post" method (it if is get you'll see the form
value on the querystring).

Once you see what goes wrong in the client side HTML you'll be able to
change your code server side so that it is properly generated.

Patrice

"Benjamin Bittner" <benjamin_bittner[a_t]nospam.web.de> a écrit dans le
message de news:eg**************@TK2MSFTNGP09.phx.gbl...
Hi all,
i have a simple user control (domaincheck.ascx):

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="domaincheck.ascx.vb" Inherits="loopline_prod.bb.domaincheck"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<table>
<tr>
<td>
Domain name: <asp:TextBox id="txtDomain" runat="server" />
<asp:Button id="btnQuery" text="Query!" runat="server" />
<BR><HR width="100%"><BR>
<asp:label id="lblResult" runat="server" />
</td>
</tr>
</table>

and this code in my codebehind:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Page.IsPostBack Then
lblResult.Text = "Test: " & txtDomain.Text
End If
End Sub

the enclosing index.aspx, where the domaincheck.ascx is loaded, has a form
tag like this:
<form runat="server></form>

Thx in advance.
Regards Benjamin

Nov 18 '05 #2

P: n/a
Hallo Patrice
"Patrice" <no****@nowhere.com> schrieb im Newsbeitrag
news:uJ**************@TK2MSFTNGP09.phx.gbl...
The weird thing is, that after the postback, the right value is displayed in
the textbox, but isnt reachable with textbox.text in the codebehind module.
I think my problem is the way i load my usercontrol:

phContent.Controls.Add(Page.LoadControl("domainche ck.ascx"))

MfG Benjamin
Nov 18 '05 #3

P: n/a
How is declared txtDomain ?

For now it looks like to me that txtDomain you actually use is just another
object that is created in your main page but that doesn't belong to the ASPX
page or the user control.

The user control should expose the txtDomain value and you should get it
from there.

Patrice

"Benjamin Bittner" <benjamin_bittner[a_t]nospam.web.de> a écrit dans le
message de news:OA**************@TK2MSFTNGP11.phx.gbl...
Hallo Patrice
"Patrice" <no****@nowhere.com> schrieb im Newsbeitrag
news:uJ**************@TK2MSFTNGP09.phx.gbl...
The weird thing is, that after the postback, the right value is displayed in the textbox, but isnt reachable with textbox.text in the codebehind module. I think my problem is the way i load my usercontrol:

phContent.Controls.Add(Page.LoadControl("domainche ck.ascx"))

MfG Benjamin

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.