Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hi Developers,



I have doubt in popup window. In my application, I have two page (parent.aspx and child .aspx) . Child. Aspx which represent pop up window. In my parent.aspx page have one button "open child".When I click add button in the parent page, that will open popwindow (i.e. child.aspx).

My requirement is

1. I want to implement the class1.cs in between the two webpage. when i click button in parent page, it will call method or function in class file and the method call to open child.aspx(popup window). by using script.

2. when child.aspx (popup window) opens, the user should not allow to access the parent.aspx.. But parent page could view behind the popup window..

3. after we close the child.aspx(popup window), then only user can access the parent page(i.e.parent.aspx)

Thanks In Advance

Any one help me..........
Posted
Comments
bbirajdar 26-Jul-12 10:10am    
You have already posted the question two time before this and marked it as solved here http://www.codeproject.com/Questions/427933/How-to-call-anther-webform-by-using-Business-logic

and received answers here http://www.codeproject.com/Questions/427311/Doubt-in-popup-window-Urgent-requirement

This is your third repost

Call function callchildwindow() as shown below from parent page

JavaScript
<script language="javascript">
        function callchildwindow() {           
           var s="height:200;width:200";          
           window.showModalDialog("Child.aspx", "new", s);        
        }
    </script>
 
Share this answer
 
v2
Follow following Steps to Solve your Problem...

For (1)

Open Solution Explorer..Right Click in Project Name..Select add ASP.NET Folder & Select App_Code folder...

Now Select Newly Added App_Code folder.Right Click on it..Select Add New Item..Select Class from list give appropriate name & then add..Suppose class name is Class1.cs

Now Open this Class1.cs & Write required functions in it using fillowing syntax

public static return-type functionname(argumentlist)
{
// function body
}


After this you can call all the function declared in this .cs file in all your aspx.cs files by this way

Class1.functionname(argumentlist);
 
Share this answer
 
Comments
shankumar_cst 27-Jul-12 3:10am    
thank ur reply... but what i want? how can i call this function from class1.cs

the following function wrote in parent source page....

<script type="text/javascript">
var newwindow;
function child(url) {
newwindow = window.open(url, 'name', 'height=250,width=320,status=yes,toolbar=no,menubar=no,left=600,top=200,,scrollbars=yes,resizable=no,titlebar=no');
if (window.focus) { newwindow.focus() }
}
</script>

this is my question please help me....
XML
To achieve your requirement no need to write that function in Class1.cs...Follow following Procedure

add following function is <script> block of .aspx page

<script type="text/javascript">
function OpenPopWin(varURL, varWindowName, varCaller, varKeyId, varWidth, varHeight) {
    var objTransparent = document.getElementById("Transparent");
    var height = document.body.clientHeight + 'px';
    document.documentElement.scrollTop = 0;


    if (navigator.appName == "Microsoft Internet Explorer")
        objTransparent.style.height = "100%";
    else
        objTransparent.style.height = height;

    objTransparent.style.width = "100%";

    objTransparent.style.visibility = 'visible';

    var varLeft = (screen.width / 2) - (varWidth / 2);
    var varTop = (screen.height / 2) - (varHeight / 2);


    popupWindow = window.open(varURL + 'Caller=' + varCaller + '&Id=' + varKeyId + '&ShowModal=1', varWindowName, 'width=' + (screen.width - 10) + 'px; height=' + (screen.height - 70) + 'px; top=' + 0 + '; left=' + 0 + '; location=0 ;resizable=1; scrollbars=1');


}
</script>

Now call this function from code behind...Here i assume that you have call this function on Button Click...Name of that button is Button1

 protected void Button1_Click(object sender, EventArgs e)
    {
        // Here i assume that you want to navigate from first.aspx(Parent Window) to second.aspx(Pop-up window)
        string str = Guid.NewGuid().ToString();
        str = str.Replace('-', '0');
        str = "w" + str;
        string Name="shankumar_cst";
    string url = "Second.aspx?Name=" + Name + "&";
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append(@"<script language='javascript'>");
        sb.Append(@"OpenPopWin('" + url + "','" + str + "', 'first.aspx', '" + -1 + "', '1024', '620');");
        sb.Append(@"</script>");
        System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "JCall2",sb.ToString(), false);
    }
 
Share this answer
 

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