Solved

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

Posted on 2012-04-11
9
377 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

13 Experts available now in Live!

Get 1:1 Help Now