Solved

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

Posted on 2012-04-11
9
420 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

690 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