Solved

reading textbox value from user control in ajax modal popup extnder

Posted on 2014-09-03
6
1,051 Views
Last Modified: 2014-10-24
Parent .aspx Form has 5 buttons. Each opens a ajax modal pop-up extender containing a user control (.uscx).
The uscx is registered, all works well.

Button opening  the modal is  below. The 5 buttons are in sequence  BtnDims1, BtnDims2  etc.  So are all the ID's


 
<asp:Button ID="BtnDims1" runat="server" Text="Dim" Width="31px" Font-Size="XX-Small" ToolTip="Enter Dimensional Load Information" TabIndex="11" />
                        <ajax:ModalPopupExtender ID="BtnDims1_Mpe" runat="server"  Enabled="True" TargetControlID="BtnDims1" PopupControlID="PNLfgtDimension1"   DropShadow="true">
                        </ajax:ModalPopupExtender>
                       <asp:Panel ID="PNLfgtDimension1"  style="display:none;"   runat="server" BorderColor="#212020" BorderStyle="Double" Visible="true" BorderWidth="6px" Width="440px" Height="150px" BackColor="White">
                        <uc1:FgtDemensions runat="server" ID="FgtDimensions1" />
                      </asp:Panel>

Open in new window

The user control has 3 text boxes (TBlength, TBWidth & TBHeight) and one cmd buttom.

After client enters the 3 values  they click the save button, things are saved and the modal closes.  
Now I want to be able to read the values from those text boxes from the parent page.(I know the inputs are still there because when I click on the modal popup button again the inputs still display.)

I can find the main child controls (the panels and forms)  in the control collection but can not successfully get the values from the text boxes.  
I found the user control using this code.
MyModal1 = CType(FindControl("BtnDims1_Mpe"), AjaxControlToolkit.ModalPopupExtender)
Dim fgtcontrol As UserControl = CType(MyModal1.FindControl("FgtDemensions1"), UserControl)

Can someone show me how to read the textboxes?     I know hoe to send vales from a child.
Not having any success at reading (pulling) from a child.

Thanks!
0
Comment
Question by:ash691
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 40303269
You can save it in the session when they click submit.

Session("height") = btnDims.text

.. Then read the value back on the main form.  Make sure you clear the values after using them.

Dim theheight as string = Session("height")
Session("height") = ""
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 40303336
If you use the developer tool in the browser you can track the hierarchy of the controls in your modal popup.
then you can try finding them using .FindControl(). But it will be bit complex.

Best way is to store that values in session or in the viewstate.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40303398
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>

attach an event to your button in your modal popup :

$("#<%= Close.ClientID %>").click(function() {
      $.cookie("TextBox1inModal", $("#<%= TextBox1.ClientID").val() );
      $.cookie("TextBox2inModal", $("#<%= TextBox2.ClientID").val() );
});

Open in new window


Now in your parent page, you can read teh value by reading the cookies :
$.cookie("TextBox1inModal");
and :
$.cookie("TextBox2inModal");
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article discusses how to implement server side field validation and display customized error messages to the client.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

737 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