Changement avec jquery non pris en compte dans le codebehind
Bonjour,
J'ai un soucis avec un formulaire. Disons que j'ai un champ input text avec un code jquery qui change sa class avec onchange. Mais quand je récupère les classes de ce champ dans le codebehind les classes sont restées les anciennes.
En cherchant sur le net, je vois qu'il faut utiliser un champ invisible pour récuperer des infos et j'ai tenté comme suit mais sans succès:
Code aspx
Code:
1 2 3
|
<input runat="server" ID="nom_val" class="form-field-input nom_val" onchange="changeField(this.id)" onfocus="focusField(this.id)" onfocusout="focusoutField(this.id)"/>
<input runat="server" ID="nom_change" Value="" /> |
Code jquery
Code:
1 2 3 4 5 6 7 8 9 10
|
function changeField(id){
$("#"+id).removeClass("form-field-default");
$("#"+id).removeClass("form-field-input");
$("#"+id).addClass("form-field-modified form-field-input");
// add a class to the hidden field (next input) to know in codebehind that this client code has been called
$("#"+id).next('input').Value = "field-change";
} |
ou alors comme ca:
Code aspx
Code:
1 2 3
|
<input runat="server" ID="nom_val" class="form-field-input nom_val" onchange="changeField(this.id)" onfocus="focusField(this.id)" onfocusout="focusoutField(this.id)"/>
<asp:HiddenField ID="nom_change" runat="server" Value="" /> |
Code jquery
Code:
1 2 3 4 5 6 7 8 9 10
|
function changeField(id){
$("#"+id).removeClass("form-field-default");
$("#"+id).removeClass("form-field-input");
$("#"+id).addClass("form-field-modified form-field-input");
// add a class to the hidden field (next input) to know in codebehind that this client code has been called
$(<%=nom_change.ClientID%>).attr("value", "field-change");
} |
Mais dans ces 2 cas, la valeur de nom_change reste vide...