Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Hidden textbox not display assigned text on unhide

Posted on 2009-12-22
Medium Priority
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
  • 2
  • 2
LVL 15

Expert Comment

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

Expert Comment

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


Expert Comment

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

Author Comment

ID: 26107332
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

Brandon_Sidley earned 0 total points
ID: 26107385
Ah, I see the problem. Enabled="False". I changed that to "True" and it appears all is well.

Thanks for the help!

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

577 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