我们可以在datgrid中的update命令之前调用javascript吗 [英] can we call javascript before update command in datgrid

查看:61
本文介绍了我们可以在datgrid中的update命令之前调用javascript吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在aspx页面中有一个datagrid,其中存在editcommand事件.我想当我单击update事件时,然后在进入.cs页面之前它将调用javascript,以便我可以检查即将到来的文本框的有效性单击编辑命令后.

谢谢,

I have a datagrid in aspx page in which editcommand event is present.I want when I click the update event then before going in .cs page it will call the javascript so that I can chek the validation of the textbox which is come after clicking the edit command.

Thanks,

推荐答案

您好,您可以在更新之前在编辑按钮"上调用JS函数.在RowDataBound事件上找到此控件,并使用以下代码设置此控件的属性.

Hi, You can call JS function on Edit Button before update. Find this control on RowDataBound event and set attribute for this control using below code.

EditButton.Attributes.Add("Onclick","javascript:return JSFunction();");




您可以在RowDataBound(e.Row.FindControl)中找到更新按钮,并将其OnClientClick分配给一小段javascript.

问候
Joachim
Hi,

You could find the update button in the RowDataBound (e.Row.FindControl) and assign it''s OnClientClick to a small piece of javascript.

Regards
Joachim


是的,默认情况下,它将首先调用客户端javascript,然后执行服务器端语句.
首先,您创建js函数,例如,
yes by default it will first call client side javascript and then execute server side statements.
First u create js function like,
function validate_text()
{
if (document.getElementById('txt_id').value == '')
 {
alert('Please Enter... !');                 document.getElementById('txt_id').focus();
return false;
 }
else
{
return true;
}
}



使用解决方案1调用创建的javascript函数.



use Solution 1 to call javascript function created.


这篇关于我们可以在datgrid中的update命令之前调用javascript吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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