Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Ajax
I am trying to return value from a modalpopupextendet's textbox to the parent page's textbox without a page refresh.
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
   <style type="text/css">
        .modalbackground
        {     background-color:Gray;
              opacity: 0.5;
              filter:Alpha(opacity=50);
        }
        .modalpopup
        {
            background-color:White;
            padding:6px 6px 6px 6px;
        }
   </style>
</head>
<body>
 
    <form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        &nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button1" runat="server" Text="Button" />
 
        <asp:Panel ID="Panel1" runat="server" CssClass="modalpopup">
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /><br />
            <asp:Button ID="Button2" runat="server" Text="Ok" />&nbsp;&nbsp;
            <asp:Button ID="Button3" runat="server" Text="Cancel" />
        </asp:Panel>
 
        <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalbackground"
         TargetControlID="Button1" PopupControlID="Panel1" CancelControlID="Button3">
        </asp:ModalPopupExtender>
 
    </div>
    </form>
</body>
</html>
 
on "Button2" click the page does a refresh which I don't want.
Also If I add more buttons to the modalpopupextender and on click of those buttons the modalpopupextender closes
 
I want the modalpopupextender to close only on the Button2 click event returning a value without refreshing the page
no othe controls on the modalpopupextender should close it.
Posted 13-Jun-13 2:51am
Edited 13-Jun-13 4:18am
v2
Comments
_Amy at 13-Jun-13 8:13am
   
Then? What is your question?
maverick12131 at 13-Jun-13 9:19am
   
Sorry, Updated my question now!!

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In your code behind write:
 
Button2.Attributes.Add("onclick","return ShowData();");
Button3.Attributes.Add("onclick","return ClosePopup();");
Add the following script in the head section of your aspx page:
<script language="javascript" type="text/javascript">
function ShowData()
{
var txtValue = document.getElementById("TextBox2").value;
alert(txtValue);
return false;
}
function ClosePopup()
{
alert('Close button clicked.');
return false;
}
</script>
 
Remember, the ID of your TextBox has to be the ID generated in HTML(view source of your page for client ID) since it is inside a panel. It may change. Alternatively, you can use Control.ClientID property in JavaScript.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 85
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 13 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100