Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello All,

I am new to AJAX and JQuery.

In my web-application I have taken one page "MasterGroup.aspx".
On the page I have one GridView and below I have one button "Add new group".

Actual Problem

I want to show the form as popup form with background page is in in-active state.
So I created one more page "AddGroup.aspx" with one textbox and a save button.

But I am not able to show the popup as well as not able to inactive the background page.

Please help me.


Thanks in advance.
Posted

 
Share this answer
 
<asp:Button ID="button"  onclick=" openPopup();return false;" />


add this Javascript Code in head
<script language="javascript">
    function openPopup() {
        window.scrollTo(0, 0);
        var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;
        var height = document.documentElement.clientHeight + document.documentElement.scrollTop;
      
 var layer = document.createElement('div');
        layer.style.zIndex = 2;
        layer.id = 'layer';
        layer.style.position = 'absolute';
        layer.style.top = '0px';
        layer.style.left = '0px';
        layer.style.height = document.documentElement.scrollHeight + 'px';
        layer.style.width = width + 'px';
        layer.style.backgroundColor = 'black';
        layer.style.opacity = '0.75';
        layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=75)");
        document.body.style.position = 'static';
        document.body.appendChild(layer);
        var size = { 'height': 220, 'width': 750 };
        var iframe = document.createElement('iframe');
        iframe.name = 'Logic Form';
        iframe.id = 'popup'; //optional
        iframe.src = 'AddGroup.aspx’;
        iframe.style.height = size.height + 'px';
        iframe.style.width = size.width + 'px';
        iframe.style.position = 'fixed';
        iframe.style.zIndex = 3;
        iframe.style.backgroundColor = 'white';
        iframe.frameborder = '0';
        iframe.style.top = ((height + document.documentElement.scrollTop) / 2) - (size.height / 2) + 'px';
        iframe.style.left = (width / 2) - (size.width / 2) + 'px';
        document.body.appendChild(iframe);
    }       
  script>

Hope this helps.
 
Share this answer
 
Comments
ambarishtv 27-Apr-11 10:26am    
Its good work
Please rewrite this code iframe.src = "AddGroup.aspx";
kulkarni.ajay 27-Apr-11 10:59am    
Thanks for the solution.
But there is a problem :

If i write :
<asp:Button ID="Button1" runat="server" Text="Show List"
onclick=" openPopup();return false;" />
I am getting error that ") expected"

and if I write like <asp:Button ID="Button1" runat="server" Text="Show List"
onclick="Button1_Click" />
and in cs file at protected void Button1_Click(object sender, EventArgs e)
{
this.Button1.Attributes.Add("onClick", "openPopup(); return false;");
}

then it works fine but for the second click of button it works fine.

Please help.
kulkarni.ajay 27-Apr-11 11:11am    
Solved.

I write the button attribute in Page_Load also.

Thanks a ton for helping in such a short time. :)
kulkarni.ajay 28-Apr-11 4:01am    
How to go back from the page "AddGroup.aspx" to our original page by a key stroke or by esc. or by a close button. Pls help. :(
jayantbramhankar 29-Apr-11 4:56am    
put a close button on right corner

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900