如何从Page.ClientScript.RegisterStartupScript()获取返回值 [英] how can i get the return value from the Page.ClientScript.RegisterStartupScript()
问题描述
亲爱的所有人,
我在按钮点击事件中使用Page.ClientScript。那么,我如何从下面的函数中获取任何值。
Page.ClientScript.RegisterStartupScript(this.GetType(),alert,validate();,是);
弹出窗口显示确认按钮,但我想知道用户点击确定或取消按钮,所以我可以根据特定的代码做。
< script type =text / javascript>
函数validate()
{
if(!confirm(''你确定要提交文件或数据吗?'))
{
返回false;
}
$ .showprogress();
}
< / script>
所以,请帮助我为此。
.showprogress();
}
< / script>
所以,请帮助我为此。
在页面上使用隐藏字段设置它在验证函数中的值,并在调用Page.ClientScript.RegisterStartupScript()后从hidenfield中检索它
exa。
< asp:HiddenField id =HiddenField1runat =server/>
< pre lang =xml> < script 类型 = text / javascript >
//在javascript中检查回发因为它在页面上注册了加载
函数validate()
{
var chkPostBack ='<% = Page.IsPostBack? true: false %> ';
if(chkPostBack =='true')
{
if(!confirm('你确定要提交文件或数据吗?')
{
document.getElementById('<% = HiddenField1.ClientID %> ')。值= 0;
}
.showprogress();
}
else
document.getElementById('<% = HiddenField1.ClientID %GT; 跨度>')值= 1;
}
< / script < span class =code-keyword>>
代码背后从hiddenfield返回它。但是第一个寄存器功能在页面上使用RegisterStartupScript
受保护 void Page_Load( object sender,EventArgs e)
{
if (!IsPostBack)
{
ScriptManager.RegisterStartupScript( this , typeof ( string ), alert, validate();, true );
}
}
受保护 void Button1_Click( object sender,EventArgs e)
{
Page.ClientScript.RegisterStartupScript( this .GetType(), alert, validate();, true );
int result1 = Convert.ToInt32(HiddenField1.Value);
}
Dear All,
I am using the Page.ClientScript inside the button click event. So, how can i get the any value from below funvtion.
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "validate();", true);
the pop up is display of confirm button but i want to know that user click the "Ok" or "Cancel" button, so i can do based on that particular code.
<script type="text/javascript"> function validate() { if(!confirm(''Are you Sure to submit your File or Data?'')) { return false; } $.showprogress(); } </script>
So, please help me for this.
.showprogress(); } </script>
So, please help me for this.
use hidden field on page set it''s value in validation function and after calling Page.ClientScript.RegisterStartupScript() retrive it from hidenfield
exa.
<asp:HiddenField id="HiddenField1" runat="server" />
<script type="text/javascript"> //in javascript fist check for postback becose it is registered on page load function validate() { var chkPostBack = '<%= Page.IsPostBack ? "true" : "false" %>'; if (chkPostBack == 'true') { if(!confirm('Are you Sure to submit your File or Data?')) { document.getElementById('<%= HiddenField1.ClientID %>').value=0; }
.showprogress(); } else document.getElementById('<%= HiddenField1.ClientID %>').value=1; } </script>
on code behind retrive it from hiddenfield.But first register fuction using RegisterStartupScript on page
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ScriptManager.RegisterStartupScript(this, typeof(string), "alert", "validate();", true); } } protected void Button1_Click(object sender, EventArgs e) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "validate();", true); int result1=Convert.ToInt32(HiddenField1.Value); }
这篇关于如何从Page.ClientScript.RegisterStartupScript()获取返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!