Attach Script to linkButton in gridview

Posted by Pavanandey under JavaScript on 4/10/2010 | Views : 6174 | Status : [Member] | Replies : 8
in GridView1_RowDataBound

LinkButton LnkAdd = (LinkButton)e.Row.FindControl("LnkAdd");
LnkAdd.Attributes.Add("OnClick", "javascript:return checkAmounts(" + aa.ClientID + "," + bb.ClientID + "," + cc.ClientID + ");");

function checkAmounts(aa, bb, cc)
{



}

i am able to fire the linkbutton click in IE for mozilla it does not work

Thanks
Pavan Kumar
Mark Answer if this fits the need



Responses

Posted by: Vuyiswamb on: 4/10/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
what Error are you getting in Firefox?

Thank you for posting at Dotnetfunda
[Administrator]

Pavanandey, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 4/12/2010 [Member] Bronze

Up
0
Down
Hi,

No Error is coming .. the javascript function is not called

Thanks
Pavan Kumar
Mark Answer if this fits the need

Pavanandey, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/12/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
there might be somewhere , where there is a problem, to debug a javascript add alerts to see if the function is reached


function checkAmounts(aa, bb, cc)
{
alert('Function Start');

///Do what ever


alert('Function End');


}


if you don't see these alerts then there is something wrong. Please try it and tell me what is happening

Thank you for posting at Dotnetfunda
[Administrator]

Pavanandey, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 4/12/2010 [Member] Bronze

Up
0
Down
Hi,

This is alredy tried added alert but even i am not able to call the function

Thanks
Pavan Kumar
Mark Answer if this fits the need

Pavanandey, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/12/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Did you declare you function in the head of your HTML ?

Did you call the function in an onClick event of the button ?

Can you show me the declaration of the button the grid and show me the declaration of your function



Thank you for posting at Dotnetfunda
[Administrator]

Pavanandey, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 4/12/2010 [Member] Bronze

Up
0
Down
Did you declare you function in the head of your HTML ?

Already i have mentioned i am able to fire it in IE, the problem is only with Mozilla so this show i have declared function in head of HTMl.

Did you call the function in an onClick event of the button ?


LinkButton LnkAdd = (LinkButton)e.Row.FindControl("LnkAdd");
LnkAdd.Attributes.Add("OnClick", "javascript:return checkAmounts(" + aa.ClientID + "," + bb.ClientID + "," + cc.ClientID + ");");

This Show i have attached the functon and called it


Can you show me the declaration of the button the grid and show me the declaration of your function


in GridView1_RowDataBound

LinkButton LnkAdd = (LinkButton)e.Row.FindControl("LnkAdd");
LnkAdd.Attributes.Add("OnClick", "javascript:return checkAmounts(" + aa.ClientID + "," + bb.ClientID + "," + cc.ClientID + ");");

function checkAmounts(aa, bb, cc)
{

}

This is code which i have already posed in my first post regarding the query


Thanks
Pavan Kumar
Mark Answer if this fits the need

Pavanandey, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: SurajRane on: 4/12/2010 [Member] Starter

Up
0
Down
hay, with your approch you are passing controls to javascript.

"+ aa.ClientID +" --> control is passed

' "+ aa.ClientID +" ' --> only Id is passed.

Try second option I think it will work.

Also make sure you that you are returning something from function.


Pavanandey, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenmanam on: 4/12/2010 [Member] Starter

Up
0
Down
this out put is link with java script
so in mozilla you must add some add-on's for run the java script
so add the java latest add-on's and try it..
add on's are in

click Tools->
Add-ons->
in Add-ons window
click get add-ons->
hear you will see "Browse all Add-ons"
click hear and search any java script
and inistal add-on's and try it...
all the best...




regards,
naveen kumar



NaveenKumar

Pavanandey, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response