How to Open PopUp Window

write this script on that aspx page from which the page is redirect to popup window
  <script type="text/javascript">
    function popup(url,width,height) {
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width=' + width + ', height=' + height;
    params += ', top=' + top + ', left=' + left;
    params += ', toolbar=no';
    params += ', menubar=no';
    params += ', resizable=yes';
    params += ', directories=no';
    params += ', scrollbars=yes';
    params += ', status=no';
    params += ', location=no';
    newwin = window.open(url, 'd', params);
    if (window.focus)
    {
        newwin.focus()
    }
    return false;
    }
    </script>

on click event

 Show(Common.GetProjectLocation(false) + "eservices/Ammendment/AmdConstitutionofPerson.aspx?" + EncryptQueryString(string.Format("repid={0}&IsOnline={1}", ViewState["tinno"].ToString(), "1")), "1050", "1000");

private void Show(string Url, string width, string height)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<script type='text/javascript'>popup('" + Url + "','" + width + "','" + height + "')</script>");
        Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "JSScript", sb.ToString());
    }

write this on common cs file

 private static string GetProejctHost(bool useSsl)
    {
        string result = "http://" + ServerVariables("HTTP_HOST");
        if (!result.EndsWith("/"))
            result += "/";
        if (useSsl)
        {
            //shared SSL certificate URL
            string sharedSslUrl = string.Empty;
            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["SharedSSLUrl"]))
                sharedSslUrl = ConfigurationManager.AppSettings["SharedSSLUrl"].Trim();

            if (!String.IsNullOrEmpty(sharedSslUrl))
            {
                //shared SSL
                result = sharedSslUrl;
            }
            else
            {
                //standard SSL
                result = result.Replace("http:/", "https:/");
            }
        }
        else
        {
            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["UseSSL"])
                && Convert.ToBoolean(ConfigurationManager.AppSettings["UseSSL"]))
            {
                //SSL is enabled

                //get shared SSL certificate URL
                string sharedSslUrl = string.Empty;
                if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["SharedSSLUrl"]))
                    sharedSslUrl = ConfigurationManager.AppSettings["SharedSSLUrl"].Trim();
                if (!String.IsNullOrEmpty(sharedSslUrl))
                {
                    //shared SSL

                    /* we need to set a store URL here (IoC.Resolve<ISettingManager>().StoreUrl property)
                     * but we cannot reference Nop.BusinessLogic.dll assembly.
                     * So we are using one more app config settings - <add key="NonSharedSSLUrl" value="http://www.yourStore.com" />
                     */
                    string nonSharedSslUrl = string.Empty;
                    if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["NonSharedSSLUrl"]))
                        nonSharedSslUrl = ConfigurationManager.AppSettings["NonSharedSSLUrl"].Trim();
                    if (string.IsNullOrEmpty(nonSharedSslUrl))
                        throw new Exception("NonSharedSSLUrl app config setting is not empty");
                    result = nonSharedSslUrl;
                }
            }
        }

        if (!result.EndsWith("/"))
            result += "/";

        return result.ToLowerInvariant();
    }
    public static string GetProjectLocation(bool useSsl)
    {
        string result = GetProejctHost(useSsl);
        if (result.EndsWith("/"))
            result = result.Substring(0, result.Length - 1);
        result = result + HttpContext.Current.Request.ApplicationPath;
        if (!result.EndsWith("/"))
            result += "/";
        return result.ToLowerInvariant();
    }

Comments

Popular posts from this blog

show (value1,value2) in one column in sql