Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I want to call JavaScript function in repeater control on button click.

If it is possible please reply

Thank......
Posted
Comments
Sunasara Imdadhusen 8-Apr-11 2:30am    
Please provide complete detail that you want, then only we will give you solution!

If you mean client click, it is possible. Lets say you have this in the ItemTemplate on your repeater
XML
<asp:Button runat="server" ID="btnSave" Text="save" />

On the ItemDataBound event of your repeater control, add this
Button saveBtn = (Button)e.Item.FindControl("btnSave");
saveBtn.Attributes.Add("onclick", "[Your Javascript Function here]");
 
Share this answer
 
v2
http://stackoverflow.com/questions/1570329/jquery-dialog-and-asp-net-repeater[^]

http://forums.asp.net/t/1670911.aspx/1[^]

I hope the above information will be helpful. If you have more concerns, please let me know.
 
Share this answer
 
Thank you guys,

I tried this, i got it...

if (e.CommandName == "Edit")
        {
            ImageButton btnedit = (ImageButton)e.Item.FindControl("imgEdit");
            string[] cmdArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
            String strJSFunctionCall = String.Format("GetAlt({0},{1},{2})", cmdArgs[0], "'"+cmdArgs[1]+"'", 0);
            btnedit.Attributes.Add("onclick", strJSFunctionCall);
        }


its started working when i placed quotes for string.

Thanks Once Again everyone.
 
Share this answer
 
Comments
Deepu S Nair 7-Jun-15 4:55am    
Did you see that the question is nearly 5 years old.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900