C# Javascript函数和<;asp:Buttoncolumn>;
我的.cs文件C# Javascript函数和<;asp:Buttoncolumn>;,c#,asp.net,C#,Asp.net,我的.cs文件 protected void Page_Load(object sender, EventArgs e) { string arg = Request.Form["__EVENTTARGET"]; string val= Request.Form["EVENTARGUMENT"]; if (arg == "Delete") { DeleteRecord(); }
protected void Page_Load(object sender, EventArgs e)
{
string arg = Request.Form["__EVENTTARGET"];
string val= Request.Form["EVENTARGUMENT"];
if (arg == "Delete")
{
DeleteRecord();
}
if (!IsPostBack)
{
PopulateDelete();
}
}
我的aspx页面Javascript方法是
<script language="javascript">
function Confirm() {
var fRet;
fRet = confirm('Do you want to Delete the record?');
if (fRet == true)
__doPostBack('Delete', fRet);
return true;
}
函数确认(){
var-fRet;
fRet=确认('是否要删除记录?');
如果(fRet==真)
__doPostBack('Delete',fRet);
返回true;
}
aspx页面中的Gridview是
<asp:DataGrid ID="dgProducts" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderWidth="1px" CellPadding="3"
BorderStyle="None" CellSpacing="2"
CssClass="HCStyle" ondeletecommand="dgProducts_DeleteCommand" >
<Columns>
<asp:BoundColumn DataField="SerialNo" HeaderText="SerialNo">
<ItemStyle HorizontalAlign="Left" Wrap="False"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Organization" HeaderText="Organization">
<ItemStyle HorizontalAlign="Left" Wrap="False"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Origin" HeaderText="Origin">
<ItemStyle HorizontalAlign="Left" Wrap="false" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Service" HeaderText="Services">
<ItemStyle HorizontalAlign="Left" Wrap="false" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Location" HeaderText="Location">
<ItemStyle HorizontalAlign="Left" Wrap="false" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Established" HeaderText="Established">
<ItemStyle HorizontalAlign="Left" Wrap="false" />
</asp:BoundColumn>
<asp:ButtonColumn CommandName="Delete" HeaderText="Delete" Text="Delete">
<ItemStyle HorizontalAlign="Left" />
</asp:ButtonColumn>
根据这一点,当我在gridview中单击Delete按钮时,会显示一个javascript文本框,如果我在JS文本框上单击yes,则应该调用DeleteRecord()方法,但我得到的arg值为“dgProducts$ctl02$ctl00”,,我如何调用DeleteRecords()方法…请帮助Meeeee您可以使用带有按钮的itemtemplatefield来实现您的目的。检查此链接。向ButtonColumn添加一个类
如下更改javascript函数
$(文档).ready(函数(){
$('.deleteButton')。单击(函数(){
返回确认('是否要删除记录?');
});
});代码>按钮列没有名为“ControlStyle CssClass”的属性