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
Solved

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

Posted on 2012-04-11
9
406 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 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 500 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 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