[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 433
  • Last Modified:

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

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
MzKitty
Asked:
MzKitty
  • 5
  • 3
3 Solutions
 
BuggyCoderCommented:
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
 
CmdoProg2Commented:
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
 
MzKittyAuthor Commented:
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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
BuggyCoderCommented:
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
 
MzKittyAuthor Commented:
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
 
BuggyCoderCommented:
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
 
MzKittyAuthor Commented:
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
 
MzKittyAuthor Commented:
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
 
MzKittyAuthor Commented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now