Hidden textbox not display assigned text on unhide

Posted on 2009-12-22
Last Modified: 2013-12-26
VS 2008

I have a simple web form designed, allowing for data entry, along with two buttons, "Submit" and "Cancel". There's a hidden panel, and a textbox within that hidden panel.

I have a ModalPopupExtender wrapped around the Submit button. The MPE is supposed to display the hidden panel (which holds the textbox) during the Submit button's onClick event.

All of this works very well, but when I assign the data that was entered to the hidden panel's textbox, the textbox does not display anything  when the MPE is displayed. Quick overview..

1- Data is entered
2 - User hits "Submit"
3 - Submit onClick Event.
  a - Data entered is assigned to variables.
  b - Hidden textbox is assigned the value of those variables (textbox.text=variables)
  c - MPE.Show() (which correctly displays hidden panel and textbox, just no actual text)

This all works A-OK, MPE displays, shows the panel and the textbox just fine, but the textbox itself doesn't display the assigned text.

During the onClick event for the Submit button, I've tried setting the hidden textbox and hidden panel to Visible=True before I assign text to the textbox, still no luck.

Suggestions? I'm not a developer by trade, so I'm guessing this might be something simple on my end.
Question by:Brandon_Sidley
    LVL 15

    Expert Comment

    In your Page_load event are u using IsPostback...
     can u post your code
    LVL 15

    Expert Comment

    if there is no ispostback.. just have a try with that like

    LVL 9

    Expert Comment

    Will it populate the data if the panel is visible to start with?

    Author Comment

    Thanks.. Not sure what I was supposed to put in the IF section, so I justI tried assigning the textbox the value of the data entered, still no go..

    Here's the VB code section..


    Partial Class _Default
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        End Sub

        Protected Sub TextBox9_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox9.Load
            TextBox9.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name
            TextBox9.Enabled = False

        End Sub

           Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged
            If DropDownList2.SelectedValue = "Deployed" Then
                UserLabel.Enabled = True
                DropDownList1.Enabled = True
                UserLabel.Enabled = False
                DropDownList1.Enabled = False
            End If
        End Sub
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

            Dim CurrentUser, DeployedUser, AssetID, AssetName, Status, CurrentState, Tier2, Tier3,         ProductName, City, Floor, Room As String
            Dim ReceivedDate, PurchaseDate, SupportDate As Date
            Dim SerialNumber, PartNumber, InvoiceNumber, Notes As String

            CurrentUser = TextBox9.Text
            AssetID = TextBox1.Text
            AssetName = TextBox2.Text
            Status = DropDownList2.SelectedValue
            CurrentState = DropDownList1.SelectedValue.ToString
            DeployedUser = DropDownList3.SelectedValue.ToString
            Tier2 = DropDownList4.SelectedValue.ToString
            Tier3 = DropDownList5.SelectedValue.ToString
            ProductName = DropDownList6.SelectedValue.ToString
            City = DropDownList7.SelectedValue.ToString
            Floor = DropDownList8.SelectedValue.ToString
            Room = TextBox4.Text
            ReceivedDate = DaintyDate1.SelectedDate
            PurchaseDate = DaintyDate2.SelectedDate
            SupportDate = DaintyDate3.SelectedDate
            SerialNumber = TextBox5.Text
            PartNumber = TextBox6.Text
            InvoiceNumber = TextBox8.Text
            Notes = TextBox3.Text

          ConfirmTextBox.Text = AssetID      

         End Sub

        Private Sub ResetFormControlValues(ByVal parent As Control)
            For Each c As Control In parent.Controls
                If c.Controls.Count > 0 Then
                    Select Case (c.GetType().ToString())
                        Case "System.Web.UI.WebControls.TextBox"
                            CType(c, TextBox).Text = ""
                        Case "System.Web.UI.WebControls.CheckBox"
                            CType(c, CheckBox).Checked = False
                        Case "System.Web.UI.WebControls.RadioButton"
                            CType(c, RadioButton).Checked = False
                        Case "System.Web.UI.WebControls.DropDownList"
                            CType(c, DropDownList).SelectedIndex = -1

                    End Select
                End If
            Next c
        End Sub

        Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

            UserLabel.Enabled = False
            DropDownList1.Enabled = False

        End Sub

    End Class

    The ASP parts ..

    Gerneral stuff..
    <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc2" %>
    <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,      PublicKeyToken=31bf3856ad364e35"      Namespace="System.Web.UI" TagPrefix="asp" %>

    For the Submit Button..


       <cc2:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button1" DisplayModalPopupID="ModalPopupExtender1" Enabled="True" />
                <cc2:ModalPopupExtender ID="ModalPopupExtender1" runat="server"  Enabled="True"
                    BackgroundCssClass="modalBackground" CancelControlID="CancelButton"
                    OkControlID="OkButton" PopupControlID="Panel1" TargetControlID="Button1" />
                <asp:Button ID="Button1" runat="server" Text="Submit" Width="137px" />

    For the Hidden panel/textbox

    <asp:Panel ID="Panel1" runat="server" BorderColor="Black" BorderStyle="Solid"
                   BorderWidth="1px" CssClass="ModalWindow" Enabled="False" Height="180px"
                   <span lang="en-us">
                   <asp:TextBox ID="ConfirmTextBox" runat="server" Columns="1"
                       CssClass="ModalWindow" ForeColor="White" Height="90px" MaxLength="90" Rows="1"
                   <br />
                   <asp:Button ID="OkButton" runat="server" Text="Ok" />
                   <asp:Button ID="CancelButton" runat="server" Text="Cancel" />



    Accepted Solution

    Ah, I see the problem. Enabled="False". I changed that to "True" and it appears all is well.

    Thanks for the help!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now