.text Property always empty on postback

Discussion in 'ASP .Net' started by Benjamin Bittner, May 14, 2004.

  1. 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
     
    Benjamin Bittner, May 14, 2004
    #1
    1. Advertising

  2. Benjamin Bittner

    Patrice Guest

    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:...
    > 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
    >
    >
     
    Patrice, May 14, 2004
    #2
    1. Advertising

  3. Hallo Patrice
    "Patrice" <> schrieb im Newsbeitrag
    news:...
    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
     
    Benjamin Bittner, May 14, 2004
    #3
  4. Benjamin Bittner

    Patrice Guest

    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:...
    > Hallo Patrice
    > "Patrice" <> schrieb im Newsbeitrag
    > news:...
    > 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
    >
    >
     
    Patrice, May 14, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page