?
Solved

Need pop-up aspx page to come up on button click

Posted on 2012-04-11
9
Medium Priority
?
425 Views
Last Modified: 2012-04-21
I am a newbie to this so I need alot of help.  I have a ticket entry webpage. when the user clicks a button (btnOrderProds), I need a pop-up window to show all of the products that are on the order being used on the ticket. (The orderID is passed to the pop-up for the sql query string that loads a gridview with the products) Then when the user closes the pop-up, the ticket entry webpage is still intact and the user can keep entering.

Thanks for any help you can give me.
Cathy
0
Comment
Question by:MzKitty
[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
  • 5
  • 3
9 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37834452
on button's client click call a javascript function as:-
<asp:button id="btnTest" runat="server" OnClientClick="ShowPopup();" />

function ShowPopup()
{
var location = "center:yes;resizable:no;dialogHeight:300px"
window.showModalDialog("http://localhost/ModalWin/ChildWebForm.aspx", '', location );
}

Open in new window

0
 
LVL 12

Expert Comment

by:CmdoProg2
ID: 37834576
From your description, I assume you want to use a dialog window. You want to open this from the client browser through a javascript that return a false value.  The trick is to update the button's onClientClick event with the url page with the orderID as the parameter.

.. code behind snippet

      btnOderProds.OnClientClick = String.Format("return javascript:OpenModalDialog('Popup.aspx?orderid={0}')", orderID)

Open in new window


...on aspx page
  <script language="javascript" type="text/javascript">
    function OpenModalDialog(url) {
      var vReturnValue;
      if (url != null) {
        vReturnValue = window.showModalDialog(url, "#1", "dialogHeight: 600px; dialogWidth: 600px; dialogTop: 190px; dialogLeft: 220px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
       }
      return false;
    }
  </script>

Open in new window

0
 

Author Comment

by:MzKitty
ID: 37835001
I also need to pass it a parameter for the sql select query to use.  How do I get the value of txtOrderID.text to the dialog window and put it in a string that has been defined as dim strOrderID as string?
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 20

Accepted Solution

by:
BuggyCoder earned 1500 total points
ID: 37835044
Markup:-

<asp:Button runat="server" ID="btnTest" onclick="btnTest_Click" 
    OnClientClick='<%#string.Format("javascript:ShowPopup({0})",txtTest.Text) %>' />

Open in new window


Js:-
function ShowPopup(val)
{
var location = "center:yes;resizable:no;dialogHeight:300px"
window.showModalDialog("http://localhost/ModalWin/ChildWebForm.aspx?val=" + val, '', location );
}

Open in new window

0
 

Author Comment

by:MzKitty
ID: 37835095
buggy,

How does the pop-up modal dialog accept the parameter so it can be extracted?  Is this a command line parameter that I need to get out of the command line?

Cathy
0
 
LVL 20

Assisted Solution

by:BuggyCoder
BuggyCoder earned 1500 total points
ID: 37835119
the parameter value will be fetched from textbox, in my case i have named it to txtTest, here is complete markup:-
<asp:TextBox runat="server" ID="txtTest" Text="123"></asp:TextBox>
    <asp:Button runat="server" ID="btnTest" onclick="btnTest_Click" 
    OnClientClick='<%#string.Format("javascript:ShowPopup({0})",txtTest.Text) %>' />

Open in new window

0
 

Assisted Solution

by:MzKitty
MzKitty earned 0 total points
ID: 37838163
When I add the textbox into the scenario, I don't get the dialog to popup.  Do I have to code a javascript into the dialog to receive the value in the textbox?

the textbox that I'm getting data from is loaded from a dropdown selection.
<asp:TextBox ID="txtOrderId" runat="server"  Width="122px" ></asp:TextBox>

my button code is:
 <asp:Button ID="btnOrderProds" runat="server"
               style="color: #000080; font-weight: 700; font-style: italic"
               Text="Show MatL on Order" Width="144px" OnclientClick='<%#string.Format("javascript:ShowPopup({0})",txtOrderID.Text) %>' />

and my Showpopup code is:
<script type="text/javascript" language="javascript" >
       function ShowPopup() {
           var location = "center:yes;resizable:no;dialogHeight:425px;dialogWidth:800px"
           //var strOrderID = txtOrderID.text
           window.showModalDialog("MatLOnOrder.aspx?val=" + val , '', location);
       }
   </script>
0
 

Author Comment

by:MzKitty
ID: 37853162
Since my code relied on a client click, the javascript had to be changed to:

  <script type="text/javascript" language="javascript">
     
     function popup() {
         var myTextField = parent.document.getElementById('<%=txtOrderId.ClientID%>');
         var obj = myTextField.value
         var location = "center:yes;resizable:no;dialogHeight:425px;dialogWidth= 800px"
          window.showModalDialog("MatLOnOrder.aspx?val=" + obj, '', location );
       }
       </script>

This code now passes the textfield value on the end of the url and I can just extract from the url.
0
 

Author Closing Comment

by:MzKitty
ID: 37875100
My solution was that the var code had to include "parent.document.getElementById('<%=txtOrderId.ClientID%>')".  My app has over 100 webpages and quite a few referenced the same txtOrderId.text field, so parent had to be included in the getElementById.  And in order to get the value from the field, it had to reference the "('<%=txtOrderId.ClientID%>')" because it was a client side click.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

800 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