Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I am using bellow code to postback from JavaScript but it seems I am not getting the argument i pass.
C#
public string postBackStr; //Defined in class

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


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


In javascript i have the function

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


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
C#
if (Page.IsPostBack)
        {
            string arg = Request["__EVENTTARGET"].ToString();
            Response.Write(arg);
}


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.
C#
if (Page.IsPostBack)
        {
            string arg = Request["__EVENTTARGET"].ToString();
            if (arg.Equals(cmbSDURN.ClientID.Replace('_', '$')))
            {
Posted
Updated 7-Jan-11 18:22pm
v3

1 solution

You should able to get the Argument values using

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


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

Mark it as answer if it is helpful
 
Share this answer
 
v3
Comments
Hiren solanki 7-Jan-11 22:59pm    
Thank you venkatesh. Take a 5.
Venkatesh Mookkan 7-Jan-11 23:05pm    
Thank you @thatraja and @Hiren
Abdul Rahman Hamidy 8-Jan-11 0:21am    
thanks I solved it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900