user786160
user786160

Reputation:

jquery in asp.net

i have a jquery

     function MoveTo() {
    var realvalues = [];
    var selectedValues = "";
    var Existingvalues = $('#<%=HFSelecteditems.ClientID%>').val();
    var currentval = "";
    $('#<%=lbItemList.ClientID%> :selected').each(function(i, selected) {
        var AddL = true;
        var ExistingarrvalL = Existingvalues.split(",");
        currentval = $(selected).val() + ";" + $(selected).text(); 
         jQuery.each(ExistingarrvalL, function(j, existingvalues) {
            if (ExistingarrvalL[j] == currentval) {
                AddL = false;
                return false;
            }
        });
        if (AddL) {
            selectedValues += currentval + ",";
        }
    });
    Existingvalues += selectedValues;
    alert(Existingvalues);
    $('#<%=HFSelecteditems.ClientID%>').val(Existingvalues);
    UpdateSelectedList();
}

how can i access the value of Existingvalues in code behind?im using c#

Upvotes: 1

Views: 63

Answers (3)

Prabhakaran Parthipan
Prabhakaran Parthipan

Reputation: 4273

Use hidden variable and store Existingvalues values and get that value in code behind client side:

$("#hdExistingvalues").val(Existingvalues);

Code behind:

string str =hdExistingvalues.value;

Upvotes: 0

Lester
Lester

Reputation: 4413

You can't. Existingvalues exists on the client-side (the users browser) so you would need to pass it to the server-side somehow.

You can do this either by sending it as a query string parameter or saving it in a hidden field and doing a postback.

Upvotes: 0

Pranay Rana
Pranay Rana

Reputation: 176886

you can do this

var txtUsernameID = '<%= txtUsername.ClientID %>';
than 
txtUserNameId = '#' + txtUserNameId;
var val = $(txtUserNameId).val();

Upvotes: 1

Related Questions