我想显示来自服务器端的确认消息,然后显示“确定”或“取消”我想执行服务器端方法的事件
我有一个像这样的按钮:-
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxPanel ID="mainAjaxPanelContentManager" runat="server" Height="100%" LoadingPanelID="contentManagerRadAjaxLoadingPanel" OnAjaxRequest="ContentManagerAjaxRequest"></telerik:RadAjaxPanel>
<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png"
Height="20px" OnClientClick="test()"/>
然后我有这样的 javascript 函数:-
function test()
{
var result;
var r = confirm("Duplicate Serial Number - DO you want to change it?");
$find("<%= mainAjaxPanelContentManager.ClientID %>").ajaxRequest(r);
}
它成功运行以下服务器端方法:-
protected void ContentManagerAjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
if (e.Argument.ToLower() == "true")
{
}
}
但是当我这样做时:-
<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png"
Height="20px" OnClick="btnadd_Click"/>
protected void btnadd_Click(object sender, ImageClickEventArgs e)
{
showMessageBox("Hello");
}
protected void showMessageBox(string message)
{
string sScript = "";
sScript += "var result;";
sScript += "var r = confirm('Duplicate Serial Number - DO you want to change it');";
sScript += mainAjaxPanelContentManager + ".ajaxRequest(r);";
ScriptManager.RegisterStartupScript(this, this.GetType(), "confirm", sScript, true);
}
那么它不会执行服务器端方法 ContentManagerAjaxRequest
和抛出“对象不支持此属性或方法”的异常。
我认为服务器端不支持ajaxRequest()
。但它的替代品是什么?
实际上我的问题是我想显示来自服务器端的确认消息,然后在“确定”或“取消”事件上我想执行服务器端方法,例如“ContentManagerAjaxRequest
”
I have a button like this:-
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxPanel ID="mainAjaxPanelContentManager" runat="server" Height="100%" LoadingPanelID="contentManagerRadAjaxLoadingPanel" OnAjaxRequest="ContentManagerAjaxRequest"></telerik:RadAjaxPanel>
<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png"
Height="20px" OnClientClick="test()"/>
then i have javascript function like this:-
function test()
{
var result;
var r = confirm("Duplicate Serial Number - DO you want to change it?");
$find("<%= mainAjaxPanelContentManager.ClientID %>").ajaxRequest(r);
}
which successfully runs following server side method:-
protected void ContentManagerAjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
if (e.Argument.ToLower() == "true")
{
}
}
But when i do like this:-
<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png"
Height="20px" OnClick="btnadd_Click"/>
protected void btnadd_Click(object sender, ImageClickEventArgs e)
{
showMessageBox("Hello");
}
protected void showMessageBox(string message)
{
string sScript = "";
sScript += "var result;";
sScript += "var r = confirm('Duplicate Serial Number - DO you want to change it');";
sScript += mainAjaxPanelContentManager + ".ajaxRequest(r);";
ScriptManager.RegisterStartupScript(this, this.GetType(), "confirm", sScript, true);
}
then it not execute server side method ContentManagerAjaxRequest
and throws an exception that "Object doesn't support this property or method".
i think ajaxRequest()
not supported on serverside. but wahts is its alter native?
actually my problem is that i want to show the confirm message from the server side then on the "OK" or "Cancel" event i want to execute a server side method like "ContentManagerAjaxRequest
"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那应该做什么?
难道你不想要这样的东西吗(你一开始就已经这么做了)?
What is that supposed to do?
Don't you want something like this (which you already did in the beginning)?