按钮上的标签和TextBox值单击为警报

时间:2018-05-21 11:38:45

标签: c# jquery webforms

我无需帮助。

点击按钮,我需要屏幕上以警报形式显示的标签和txtBox'中的值。

它应该是这样的:

  1. Label0(value)txtBoxOpis0(value)

  2. Label1(value)txtBoxOpis1(value)....

  3. 该表有更多的字段,我在这个例子中只复制了两行。

    <table id="MainContent_gvKarakteristike" style="color:#333333;border-collapse:collapse;" cellspacing="0" cellpadding="4">
            <tbody><tr style="color:White;background-color:#507CD1;font-weight:bold;">
                <th scope="col">Karakteristike</th><th scope="col">&nbsp;</th><th scope="col">Opis</th>
            </tr><tr style="background-color:#EFF3FB;">
                <td>
                            <span id="MainContent_gvKarakteristike_Karakteristike_0" mycustomattr="foo" margin-left="100px" style="display:inline-block;font-family:Georgia;height:30px;width:150px;">GRP Total_Thickness</span>
    
    
    
                        </td><td>
                            <span id="MainContent_gvKarakteristike_Label_0" class="IDKarakteristike" margin-left="100px" style="display:inline-block;font-family:Georgia;height:30px;width:150px;">1</span>
    
                        </td><td>                      
    
                            <input name="ctl00$MainContent$gvKarakteristike$ctl02$txtBoxOpis" id="MainContent_gvKarakteristike_txtBoxOpis_0" margin-left="100px" style="font-family:Georgia;height:28px;width:130px;" type="text">
    
                        </td>
            </tr><tr style="background-color:White;">
                <td>
                            <span id="MainContent_gvKarakteristike_Karakteristike_1" mycustomattr="foo" margin-left="100px" style="display:inline-block;font-family:Georgia;height:30px;width:150px;">GRP Wear Layer thickness</span>
    
    
    
                        </td><td>
                            <span id="MainContent_gvKarakteristike_Label_1" class="IDKarakteristike" margin-left="100px" style="display:inline-block;font-family:Georgia;height:30px;width:150px;">2</span>
    
    
                        </td><td>
    
    
                            <input name="ctl00$MainContent$gvKarakteristike$ctl03$txtBoxOpis" id="MainContent_gvKarakteristike_txtBoxOpis_1" margin-left="100px" style="font-family:Georgia;height:28px;width:130px;" type="text">
    
                        </td>
            </tr><tr style="background-color:#EFF3FB;">
                <td>
    

    这是按钮

    <input name="ctl00$MainContent$btnButton" value="Save" onclick="return false;" id="MainContent_btnButton" autopostback="false" type="submit">
    

    提前致谢!

1 个答案:

答案 0 :(得分:0)

你可以这样做

$('#MainContent_btnButton').click(function () {
    alert(
    'Label0('+
    $("#MainContent_gvKarakteristike_Label_1").text()+
    ')\n(txtBoxOpis0'+
    $("#MainContent_gvKarakteristike_txtBoxOpis_1").text()+
    ')'
    );
});