calling javascript function

Asked By srikar
09-Sep-10 02:12 AM
Earn up to 0 extra points for answering this tough question.
am calling javascript function on page load is it right r wrong plz currect me.

 protected void Page_Load(object sender, EventArgs e)
    {
      Button1.Attributes["onclck"] = "javascript:return(createCustomAlert);";
    }

  re: calling javascript function

Reena Jain replied to srikar
09-Sep-10 02:19 AM
hi,

yes it is correct srikar

  re: calling javascript function

srikar replied to Reena Jain
09-Sep-10 02:20 AM
k

  re: calling javascript function

Sagar P replied to srikar
09-Sep-10 02:34 AM
Yes it is right. Even you can also do it by using;

Button1.Attributes.Add("onclick","javascript:return createCustomAlert();");

But it will not call this function on page load, it will call this function once you click on BUTTON1
  re: calling javascript function
Anand Malli replied to srikar
09-Sep-10 02:39 AM
There is another way as well...if you do not want to register on server side,you can do like following

<asp:Button id="btn" runat="server" OnClientClick="return CreateCustomAlert();" />

so there are more den one way...

thxs
  re: calling javascript function
Goniey N replied to srikar
09-Sep-10 02:48 AM
-- There Is Spelling Mistake In Your Code :

protected void Page_Load(object sender, EventArgs e)
{
//Here You Written "onclck", Actually It Is "onclick"... So Correct it....
Button1.Attributes["onclick"] = "javascript:return(createCustomAlert);";
}

-- Now This Will Work perfectly & Other Ways Which Are Already Displayed By Other That Also Works...
  re: calling javascript function
srikar replied to Goniey N
09-Sep-10 04:19 AM
kkk
Create New Account