使用的第三方控件Rad Controls 的RadGrid(类似标准的DataGrid)
在使用RadGrid_DeleteCommand删除一行时,由于要做引用检查,如果不能删除则提示用户
如
private void RadGrid_DeleteCommand(object source, GridCommandEventArgs e)
{
//如果不能删
Response.Write("<script>alert('xxx');</script>");//没有用
page.RegisterStartupScript(key,脚本);//也没有用 ClientScriptManager sm = this.ClientScript;
sm.RegisterClientScriptBlock(this.GetType(), "hwj383", "alert('fdsf');",true);//也没有用
ScriptManager.RegisterStartupScript(this, this.GetType(), "hwj383", "alert('ddd')", true);//也没有用
}
但是怎么也弹不出提示框求解,或者给一个变通的方法
在使用RadGrid_DeleteCommand删除一行时,由于要做引用检查,如果不能删除则提示用户
如
private void RadGrid_DeleteCommand(object source, GridCommandEventArgs e)
{
//如果不能删
Response.Write("<script>alert('xxx');</script>");//没有用
page.RegisterStartupScript(key,脚本);//也没有用 ClientScriptManager sm = this.ClientScript;
sm.RegisterClientScriptBlock(this.GetType(), "hwj383", "alert('fdsf');",true);//也没有用
ScriptManager.RegisterStartupScript(this, this.GetType(), "hwj383", "alert('ddd')", true);//也没有用
}
但是怎么也弹不出提示框求解,或者给一个变通的方法
解决方案 »
- 求助:Server Error in '/' Application怎么解决?
- XML序列化和反序列化的问题
- repeater的itemCommand问题
- 参数传递问题,分不多了
- 谁能第一个解决这个问题,把10 分全部送出,象把sohu.com的源码拷进aspx页面,设计页打不开了,5000多个错误,切换不过去 ,有没有好的解决
- 求救:ArgumentException: 不支持关键字: “provider”
- 请问在TABLE单元格内能否画一个斜杠分割单元格
- 如何获得一个HTTP下拉列表框控件的显示文本啊?
- 大哥救命:小弟对xml不熟,碰到一个别人写的程式,运行到某点时就拉尿,错误提示也不知啥意思?高手帮忙!万分感谢!
- 如何实现附加码?
- asp.net怎么可以记住gridview浏览的页码
- 如何在sqlserver中2000中将一个字段的ntext类型修改成varchar的类型呢
/// <summary>
/// 显示消息
/// </summary>
/// <param name="message">消息内容</param>
public void ShowMessage(string message)
{
message = message.Replace("'", "").Replace("\"", "")
.Replace("{", "(").Replace("}", ")").Replace("\n", "");
string strFormat = "<script>javascript:alert('{0}')</script>"; Response.Write(String.Format(strFormat, message));
} /// <summary>
/// 显示消息,用于使用UpdatePanel的情况
/// </summary>
/// <param name="message">消息内容</param>
public void AJAXShowMessage(string message)
{
message = message.Replace("'", "").Replace("\"", "")
.Replace("{", "(").Replace("}", ")").Replace("\n", "");
string strFormat = "alert('{0}')";
strFormat = String.Format(strFormat, message); ScriptManager.RegisterStartupScript(this, this.GetType(), System.Guid.NewGuid().ToString("N").Substring(1, 4), strFormat, true);
}
private void infolist_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType!=ListItemType.Header&& .Item.ItemType!=ListItemType.Footer)
{
LinkButton deleteButton = (LinkButton) e.Item.Cells[4].Controls[0];
deleteButton.Attributes["OnClick"]="return confirm('你确认要删除吗?')";
}
}
有用吗?不过看起来和我的代码没啥区别呢?
我没有用到UpdatePanel
由于是第三方控件.可能要多检查一下
先去 RadGrid_DeleteCommand看看,如果是e.Command之类的 等于 Delete
我跟代码是执行了的,我想原因是这样的吧:
由于是用的第3方控件RadControls,支持ajax无刷新Grid,所以Response.Write无法输出,当然RegisterStartupScript也不能注册(或者像7楼的朋友说的没有触发),去掉ajax支持,则没有问题
我的怎么好用呢。
这是微软ajax里面的