使用javascript函数调用gridview行命令事件 [英] Call gridview row command event using javascript function

查看:108
本文介绍了使用javascript函数调用gridview行命令事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过javascript函数调用gridview rowcommand事件,我也希望通过javascript函数发送命令参数,我在google上搜索了很多但没有得到任何解决方案。

如果任何人都有解决方案帮助我。



提前谢谢。

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.

推荐答案

你可以打电话它使用ScriptManager

You can call it using ScriptManager
ScriptManager.RegisterStartupScript(this, this.GetType(), "myalert", "alert('File already exists.');", true);


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>

------------------------------------------ --------
服务器端


protected void GridView1_RowCommand(object sender,GridViewCommandEventArgs e)
{
if(e。 CommandName.Equals(COMMAND_TO_FIRE))
{
' + paramID); } } </script> -------------------------------------------------- On Server Side protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("COMMAND_TO_FIRE") ) {


这篇关于使用javascript函数调用gridview行命令事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆