A day with .Net

My day to day experince in .net

Pop up window in asp.net

Posted by vivekcek on July 21, 2009

To open a page as pop up we can use the following code

string url = Program.GetAppUrlBase(Request) + "/folder/folder1/mypage.aspx?tid=" + e.CommandArgument.ToString();
            string script = "window.open('" + url + 

"','Trans','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Transaction", script, true);

where GetAppUrlBase(Request) is a function written on Program.cs file in App_Code folder to get the base Url of application

public static string GetAppUrlBase(HttpRequest request)
    {
        string nUrl = request.ApplicationPath;

        if (nUrl == null || nUrl.Trim('/') == string.Empty)
            nUrl = request.Url.GetLeftPart(UriPartial.Authority).TrimEnd('/');
        else
            nUrl = request.Url.GetLeftPart(UriPartial.Authority).TrimEnd('/') + "/" + nUrl.Trim('/');

        return nUrl;
    }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s