如何在模式框上分配文本框值後獲取代碼隱藏文本框的值?將文本框值分配到同一頁上的模式框
這是模態盒如何出現在頁面上:
<div id="dialog-form" title="Modal Box">
<asp:TextBox ID="Textbox1" runat="server" ReadOnly="True">
<asp:Button ID="Save_Button" runat="server" Text="Save"></asp:Button>
</div>
爲了分配上Textbox1
的價值,我附上一個JavaScript函數來LinkButton的上一個GridView(這裏沒有顯示的代碼)通過代碼隱藏基於LinkButton的點擊:
Dim myLinkButton As LinkButton
For i As Integer = 0 To GV1.Rows.Count - 1
myLinkButton = DirectCast(GV1.Rows(i).Cells(1).FindControl("LinkButton"), LinkButton)
myLinkButton.Attributes.Add("onclick", "shopModalPopup('" + .Rows(i).Cells(0).Text & "'); return false;")
Next
Rows(i).Cells(0)
是在GridView的第一列,它是「ID
」。這個ID
將被分配到Textbox1
而Linkbutton點擊。
的JavaScript代碼是相同的頁面GridView的代碼上:
<script>
var grid_modal_options = {
height: 450,
width: 550,
modal: true
};
function shopModalPopup(id) {
var DataField = id;
grid_modal_options.open = function() {
$('#dialog-form #Textbox1').val(DataField);
};
$("#dialog-form").dialog(grid_modal_options);
$("#dialog-form").parent().appendTo('form:first');
}
</script>
當我點擊模態盒保存按鈕,在Textbox1
值不能對代碼後來居上。它總是返回空值。怎麼做?非常感謝你。
爲什麼你使用是使用asp文本框的方式 – 2012-04-24 02:41:31
@COLDTOLD:對不起,我已經編輯了上面的代碼。我正在使用asp:textbox,但仍然無法獲得值。 – 2012-04-24 02:45:31