如何在asp.net中回发后保留Textbox的状态 [英] How to retain Textbox's State after Postback in asp.net

查看:100
本文介绍了如何在asp.net中回发后保留Textbox的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一张有格栅视图的表格。保存按钮.Gridview有一个复选框&如果我单击复选框并且如果选中它,则该行中的文本框将变为禁用状态,如果未选中该行,则该行中的文本框将变为启用状态。为此,我使用以下JQuery代码&它工作正常。



<前lang =Javascript> $(文件)。ready( function (){
try {
$( input [type = checkbox] [id * = chkChild])。click(函数(){
if this .checked){
$( this )。nearest( tr).find( input [type = text] [id * = txtRemark]) .attr( disabled true );
$( this )。nearest( tr)。find( input [type = text] [id * = txtRemark] )。val( NA);
$( this )。nearest( tr)。find( input [type = text] [id * = txtRemark])聚焦();
} 其他 {

$()。最近( tr)。find( input [type = text] [id * = txtRemark])。attr( disabled false );
$( this )。nearest( tr)。find( input [type = text] [id * = txtRemark])。val( );
$( this )。nearest( tr)。find( input [type = text] [id * = txtRemark])聚焦();
}
});
} catch (e){
alert(e);
}
});





但是回发后如果我的文本框被禁用,那么它就不会保留它禁用状态&它成为启用。所以请告诉我如何保持其状态。

解决方案

document )。ready( function (){
try {


input [type = checkbox] [id * = chkChild])。click( function (){
if this .checked){


this )。nearest( tr)。find( input [type = text] [id * = txtRemark])。attr( disabled);

I'm working on a form which is having a gridview & save button.Gridview has a checkbox & a textbox.If i clicked on checkbox and if it is checked,the textbox in that row becomes disable and if it is unchecked,the textbox in that row becomes enable.For this purpose i'm using following JQuery code & it is working properly.

$(document).ready(function () {
    try {
        $("input[type=checkbox][id*=chkChild]").click(function () {
            if (this.checked) {
                $(this).closest("tr").find("input[type=text][id*=txtRemark]").attr("disabled", true);
                $(this).closest("tr").find("input[type=text][id*=txtRemark]").val("NA");
                $(this).closest("tr").find("input[type=text][id*=txtRemark]").focus();
            } else {

                $(this).closest("tr").find("input[type=text][id*=txtRemark]").attr("disabled", false);
                $(this).closest("tr").find("input[type=text][id*=txtRemark]").val("");
                $(this).closest("tr").find("input[type=text][id*=txtRemark]").focus();
            }
        });
    } catch (e) {
        alert(e);
    }
});



But after postback if i the textbox is disabled then it is not retaining its disable state & it becomes enable. So please tell me how to maintain its state.

解决方案

(document).ready(function () { try {


("input[type=checkbox][id*=chkChild]").click(function () { if (this.checked) {


(this).closest("tr").find("input[type=text][id*=txtRemark]").attr("disabled", true);


这篇关于如何在asp.net中回发后保留Textbox的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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