本文介绍了当我点击gridview列数据(按钮)时,如何在代码中使用javascript警报消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,



当我点击gridview列数据(即按钮)时如何在代码中使用javascript警告消息?



此代码通常在c#页面中工作,



Dear Sir,

How to use javascript alert message in code behind when I click gridview Column data(ie. Button)?

This code normally Working in c# page,

ScriptManager.RegisterStartupScript(Page, this.GetType(), "AlertMessage", "<script language=\"javascript\"  type=\"text/javascript\">;alert('Mohan');</script>", false);



但是当我点击gridview数据或记录它不显示时。



请帮帮我,如何显示,当我点击gridview按钮



by Mohan。


But when I Click gridview data or record its not display.

Please Help me, How to display, when I click gridview button

by Mohan.

推荐答案

<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton3" runat="server" CommandName="Delete" Height="12px"

ImageUrl="~/images/delete.png" ToolTip="Delete Record" Width="12px" OnClientClick="return delrecord();" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" Wrap="False" Width="30px" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="False" Width="30px" />
</asp:TemplateField>





你可以看到js函数调用delrecord()就好了,





as you can see js function delrecord() is called which is like,

function delrecord() {
    if (confirm("Are you sure want to Delete Record ?")) {
        return true;
    }
    else {
        return false;
    }
}


ScriptManager.RegisterStartupScript(
       this,
       typeof(Page),
       "Alert",
       "<script>alert('" + sMessage + "');</script>",
       false);







on button onclick event.



这篇关于当我点击gridview列数据(按钮)时,如何在代码中使用javascript警报消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:53