-1

4つのテキストボックスとラジオボタンを含むaspページのフォームビューがあります。編集ボタンをクリックすると、textbox1、textbox2、textbox3に値が存在する場合、radiobutton1とtextbox4が表示されます(つまり、textboxes(1,2,3)のいずれかが空の場合、textbox1とradiobuttonは表示されません)

4

2 に答える 2

1

jQuery を使用している場合:

$("#idOfEditButton").live('click', function(){

    if(!$('#idOfTxt1').val() || !$('#idOfTxt2').val() || !$('#idOfTxt3').val()){
        $('#idOfRadio').hide();
        $('#idOfTxt4').hide();   
    }
    else{
        $('#idOfRadio').show();
        $('#idOfTxt4').show();  
    }
});

編集

クラスを使用$('.classNameOfAllTxt')して、if ステートメントを追加することもできます (1 回のみ)。そして$('.classfTxt4AndRadio').show(); // or hide

于 2012-07-05T18:02:46.380 に答える
0

フォームビュー編集イベントで、コントロールを見つけて、テキストボックスに次のようなテキストが含まれているかどうかを確認します

TextBox textbox1 = formView.FindControl("TextBox1") as TextBox;

同様に、TextBox2、TextBox3、TextBox4、および Radiobutton1 を見つけます。

次に比較

if(textbox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty)
{
    textbox4.Visible = true;
    Radiobutton1.Visible = true;
}
else
{
    // set visibility to false
}

以下のイベントでこれを行います

    protected void FormView1_ModeChanged(object sender, EventArgs e)
    {

        if (FormView1.CurrentMode == System.Web.UI.WebControls.FormViewMode.Edit)
        {
            **// Find Controls and Check ConditionHere**
        }
    }

それを試してみてください。それが役に立てば幸い。

Javascriptの場合、次のようなものを試してください:

 function Check() {
        var b = document.getElementById("<%= FormView1.FindControl("textBox1").ClientID%>");
        var a = document.getElementById("<%= FormView1.FindControl("textBox2").ClientID%>");

        if(a.innerText === "" && b.innerText == "")
        {
              // find the control like above and set visibility to false
              var textbox4 = ....;
              textbox4.visibility = "block"; // attribute for visibility is not verified by me, check to see the correct one if you have problem hidding or showing.
        }

        return false;

    }
于 2012-07-05T18:03:49.373 に答える