.text Property always empty on postback

  • Thread starter Thread starter Benjamin Bittner
  • Start date Start date
B

Benjamin Bittner

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
 
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
 
Hallo Patrice
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("domaincheck.ascx"))

MfG Benjamin
 
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
 
Back
Top