Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
i want to invoke the gridview rowcommand event through javascript function, also i want to send the command arguments through the javascript function , i have search lots of on google but not getting any solution.
If any one has solution for this help me.

Thank you in advance.
Posted
Updated 27-Sep-17 8:40am

You can call it using ScriptManager
C#
ScriptManager.RegisterStartupScript(this, this.GetType(), "myalert", "alert('File already exists.');", true);
 
Share this answer
 
Comments
[no name] 11-Mar-14 7:00am    
It only call to javascript function not event, i want to call event and pass command arguments
Check this pseudo-code

First we need to send a postback with __doPostBack, on the control using uniqueID then on server side just add the rowCommand event handler, and at the ASPX put the Page.EnableEventValidation as false.

Client Side

In ASPX
<%@ Page EnableEventValidation="false" ...


--------------------------------------------------

In JavaScript

<script>
	   
function deleteFile(paramID) {
  if (paramID>0) 
  { 
	            
    __doPostBack('<%=GridView1.UniqueID%>', 'COMMAND_TO_FIRE$' + paramID);
	            
   }
}

</script>

--------------------------------------------------
On Server Side


   protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("COMMAND_TO_FIRE") )
            {
 
Share this answer
 

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