__doPostback来自Javascript给出了错误的参数 [英] __doPostback from Javascript gives wrong Argument

查看:90
本文介绍了__doPostback来自Javascript给出了错误的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
我正在使用波纹管代码从JavaScript回发,但似乎我没有得到我通过的论据.

Dear All,
I am using bellow code to postback from JavaScript but it seems I am not getting the argument i pass.

public string postBackStr; //Defined in class

postBackStr = Page.ClientScript.GetPostBackEventReference(this, "myArgument"); //Defined in Page Load





textBox = cmbCo.FindControl("TextBox") as TextBox;
if (textBox != null)
{textBox.Attributes.Add("onblur", "return getMinistryCode(this);"); // This is In Render
}



在javascript中,我具有功能



In javascript i have the function

function getMinistryCode(txt) {
var cmbSDURN = document.getElementById(document.getElementById('<%= this.cmbSDURN.ClientID %>').id + "_HiddenField");
if (cmbSDURN.value == 0) {
   alert('Please Select SDURN');
   <%= postBackStr %>
 }
 }



回发发生了,但是我正在获取cmbCo ClientID,让我提到cmbCo是Ajax 3.5 ComboBox,并且我正在分配onblur.

参数值的代码是



The postback occurs but i am getting cmbCo ClientID, let me mention that cmbCo is Ajax 3.5 ComboBox and I am assigning onblur.

And the code for argument value is

if (Page.IsPostBack)
        {
            string arg = Request["__EVENTTARGET"].ToString();
            Response.Write(arg);
}



正如我所说的arg返回cmbCo的clientID一样,如何获取通过客户端脚本传递的参数?

我找到了贝娄的解决方案.



As i stated the arg return the clientID of cmbCo, how can i get the argument which i am passing through Client Script?

I found the solution by bellow.

if (Page.IsPostBack)
        {
            string arg = Request["__EVENTTARGET"].ToString();
            if (arg.Equals(cmbSDURN.ClientID.Replace('_', '$')))
            {

推荐答案

'))) {
'))) {


您应该能够使用
获取Argument值
You should able to get the Argument values using

string arg = Request["__EVENTARGUMENT"].ToString();



还可以看看下面的这篇文章
要知道哪个控件引发了PostBack. [



Also take a look at this following article
Way to know which control have raised PostBack.[^]

Mark it as answer if it is helpful


这篇关于__doPostback来自Javascript给出了错误的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆