Hi,

If you want to use external javascript you will have to link it to the form with something like

<script language="JavaScript" src="full or relative path to external javascript file" type="text/javascript"></script>

Have the above line in the html code of your page.

And then for a button server control you should always try to add the attribute to "onclientclick" event of the button and not onclick.

So do something like

strUrl = "can contain the name of any page which you want to open in a javascript window";
Button1.Attributes.Add("onclientclick", "return popWin2('" + strUrl + "');");

That should do the trick.

Warm REgards,


Quote Originally Posted by johnsonlim026 View Post
Hi, i have a external javascript. The path to this is :/javascrpit/MyJavaScript.js
I would like to pass the form address as a parameter to the function so that i can have my pop up coding reuse while it can perform the pop up for different form.I have already tested that my javascript function is working as i show below

My coding in the parent page is as below:

Code:
If Page.IsPostBack = False Then

Page.ClientScript.RegisterClientScriptInclude("MyScript", "javascript/MyJavaScript.js")

   ' this is the coding that working and give me a pop up
   'Button1.Attributes.Add("onClick", "return popWin();")


   'now i want to customize it so that it can pop up the form based on the paramter i pass in.But it does not work

            strUrl = "Default2.aspx"
            Button1.Attributes.Add("onclick", "return ppopWin2('" + "Default2.aspx" + "');

        End If
My external javascript function is as below

Code:
  function popWin(llInp)	{			
        window.open("Default2.aspx","MyBasket","width=800,scrollbars=yes,height=800");			
        return false;
          }	 
          
 function popWin2(url)	{			
        window.open(url,"MyBasket","width=800,scrollbars=yes,height=800");			
        return false;
          }
Does anyone has anyidea on this ??

The second question i want to ask here is :

(a).How do i start to learn javascrpt. How do i learn to make the interaction between the servr code and the javascript? I have the internet whole day but and reading from www.3cschool.com but it does not help much in understanding how to use this in coding.. Does anyone mind to share his experience here ?