.text Property always empty on postback

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
 
P

Patrice

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
 
B

Benjamin Bittner

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
 
P

Patrice

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top