Dear all,
I used to use pure ASP.Net code like this :

Protected Sub CmdLocateCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim S As String
        If TxtCustomerID.Text.Trim = "" Then
            S =  "<SCRIPT>var w = 0, h = 0;if (document.all || document.layers) { w = screen.availWidth;   h = screen.availHeight; }var popW = 900, popH = 500;var leftc = (w - popW) / 2, topc = (h - popH) / 2;w_Locate = window.open('Browse/LocateAllCustomerMaster.aspx?CustomerID=form1.TxtCustomerID&CustomerName=form1.TxtCustomerName&OnClick=CmdLocateCustomer','w_Locate','scrollbars=yes,left=' + leftc + ', top=' + topc + ',width=900,height=500');w_Locate.focus();</SCRIPT>"
            If ClientScript.IsClientScriptBlockRegistered("s") = False Then
                ClientScript.RegisterClientScriptBlock(Me.GetType(), "s", S)
            End If 
        End If
    End Sub

Now, I want to convert it into AJAX.Net.
What code do I have to use to run JavaScript code like above function ?
I tried this one :

Protected Sub CmdLocateCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If TxtCustomerID.Text.Trim = "" Then
            ScriptManager.RegisterClientScriptBlock(Page, Me.GetType(), "s", <SCRIPT>var w = 0, h = 0;if (document.all || document.layers) { w = screen.availWidth;   h = screen.availHeight; }var popW = 900, popH = 500;var leftc = (w - popW) / 2, topc = (h - popH) / 2;w_Locate = window.open('Browse/LocateAllCustomerMaster.aspx?CustomerID=form1.TxtCustomerID&CustomerName=form1.TxtCustomerName&OnClick=CmdLocateCustomer','w_Locate','scrollbars=yes,left=' + leftc + ', top=' + topc + ',width=900,height=500');w_Locate.focus();</SCRIPT>
, True)
        End If
    End Sub

but failed....:'(

Thanks.

Well partner in c# i will do this, probably you can translate this to vb.

System.Text.StringBuilder sbScript = new System.Text.StringBuilder("");

            sbScript.Append("<script language='javascript'>");
            sbScript.Append("var w=0, h=0;");
            sbScript.Append("if(document.all || document.layers)");
            sbScript.Append("{");
            sbScript.Append("w=screen.availWidth;");
            sbScript.Append("h=screen.availHeight;");
            sbScript.Append("}");
            sbScript.Append("var popW = 900,");
            sbScript.Append("popH = 500;");
            sbScript.Append("var leftc = ( w - popW) / 2,");
            sbScript.Append("topc = (h - popH) / 2;");
            sbScript.Append("window.open('");
            sbScript.Append("http://www.google.com");
            sbScript.Append("', 'w_Locate',");
            sbScript.Append("'left='+leftc+',top='+topc+',width=900, height=500, menubar=yes, resizable=no');");
            sbScript.Append("w_Locate.focus();<");
            sbScript.Append("/script>");

            ScriptManager.RegisterStartupScript(this, this.GetType(), "@@@@MyPopUpScript", sbScript.ToString(), false);

Hope that help you.

Well partner in c# i will do this, probably you can translate this to vb.

System.Text.StringBuilder sbScript = new System.Text.StringBuilder("");

            sbScript.Append("<script language='javascript'>");
            sbScript.Append("var w=0, h=0;");
            sbScript.Append("if(document.all || document.layers)");
            sbScript.Append("{");
            sbScript.Append("w=screen.availWidth;");
            sbScript.Append("h=screen.availHeight;");
            sbScript.Append("}");
            sbScript.Append("var popW = 900,");
            sbScript.Append("popH = 500;");
            sbScript.Append("var leftc = ( w - popW) / 2,");
            sbScript.Append("topc = (h - popH) / 2;");
            sbScript.Append("window.open('");
            sbScript.Append("http://www.google.com");
            sbScript.Append("', 'w_Locate',");
            sbScript.Append("'left='+leftc+',top='+topc+',width=900, height=500, menubar=yes, resizable=no');");
            sbScript.Append("w_Locate.focus();<");
            sbScript.Append("/script>");

            ScriptManager.RegisterStartupScript(this, this.GetType(), "@@@@MyPopUpScript", sbScript.ToString(), false);

Hope that help you.

thanks...it works....
I made mistake in

ScriptManager.RegisterClientScriptBlock(Page, Me.GetType(), "s", "<SCRIPT>var w = 0, h = 0;if (document.all || document.layers) { w = screen.availWidth;   h = screen.availHeight; }var popW = 900, popH = 500;var leftc = (w - popW) / 2, topc = (h - popH) / 2;w_Locate = window.open('Browse/LocateAllCustomerMaster.aspx?CustomerID=form1.TxtCustomerID&CustomerName=form1.TxtCustomerName&OnClick=CmdLocateCustomer','w_Locate','scrollbars=yes,left=' + leftc + ', top=' + topc + ',width=900,height=500');w_Locate.focus();</SCRIPT>", [B]False[/B])

Good. take care.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.