简体   繁体   中英

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#

you can do this

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

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;

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM