而在模式框单击该按钮并没有被解雇 [英] The button didn't get fired while clicked on the modal-box
问题描述
[ 在同一页面上指定一个文本框的值模态盒
已经回答了]
[Assign a Textbox Value to the modal-box on the same page
has been answered]
新的问题:
为什么在模盒按钮也不会被解雇,而我点击按钮?我缺少的东西吗?
NEW QUESTION: Why the button on the modal-box didn't get fired while I've clicked the button? Am I missing something?
我已经添加了code来处理在服务器端的单击事件:
I've added the code to handle the click event on the server side:
Protected Sub Save_Button_Click(sender As Object, e As System.EventArgs) Handles Save_Button.Click
//The code goes here
End Sub
请参见下面的标记线code。
Pls see the code below with the marked line.
我有以下code,显示模态盒一个LinkButton单击后。而且,我想要做的是如何分配的文本框的值。
I have the code below to show the modal-box after a LinkButton clicked. And, what I want to do is how to assign the Textbox value with the.
我有一个GridView:
I have a gridview:
<asp:GridView ID="GV1" runat="server" DataSourceID="DS1" >
<Columns>
<asp:BoundField HeaderText="ID" DataField="ID"/>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="Edit_Linkbutton" runat="server" CausesValidation="False" >
<asp:Image ID="Edit_Linkbutton_Image" runat="server" ImageUrl="~/edit.png"></asp:Image>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
和在同一页上(这是一个div,模式,框后显示在GridView上LinkButton的点击):
And on the same page (this is a div as modal-box to be showed after the Linkbutton on the Gridview clicked):
<div id="dialog-form" title="Modal Box">
<input type="text" id="Textbox1" />
#--------------------------------------------------------------------#
#This button didn't get fired while clicked
<asp:Button ID="Save_Button" runat="server" Text="Save"></asp:Button>
#--------------------------------------------------------------------#
</div>
然后,我附上一个JavaScript函数来LinkButton的通过code-背后:
And then I attach a Javascript function to the LinkButton through code-behind:
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
行(I).Cells(0)
是GridView的第一列,它是 ID
Rows(i).Cells(0)
is the first column on the Gridview, it is "ID
".
JavaScript的code是相同的页面在GridView code上:
The Javascript code is on the same page as the Gridview code:
<script>
function shopModalPopup(id){
//show the modal-box
$("#dialog-form").dialog("open");
// ---> How to assign the 'id' value to the Textbox1 on the modalbox?
}
$(function () {
$("#dialog-form").dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true
});
});
</script>
上面的code做开模盒,但没有值分配给在模式框的Textbox1的。
The code above do open the modal-box but not assign the value to the Textbox1 on the modal-box.
我所要问的是如何在模盒分配编号
值到 Textbox1的
?我曾尝试搜索任何相关的文章,但他们做的模态盒分离到另一个页面。但在这种情况下,模态盒是在同一页上的LinkButton的点击。我该怎么办呢?非常感谢你。
What I am gonna ask is how to assign the Id
value to the Textbox1
on the modal-box? I have try to search any relevant article but they do separate the modal-box onto the other page. But in this case, the modal-box is on the same page as the Linkbutton clicked. How can I do that? Thank you very much.
推荐答案
未经测试,但应该工作。
not tested but should work.
我想你也能避免使用内联JS和公正绑定buttonLink的单击事件
i think you can also avoid to use inline js and just bind the click event of the buttonLink
#dialog-form { display:none } /* CSS */
<script> /* JS */
/* Assuming all dialogs share the same default Settings in this grid scenario */
var grid_modal_options = {
height: 300,
width: 350,
modal: true
};
function shopModalPopup(id){
var DataField = id;
grid_modal_options.open = function(){
$('#dialog-form #Textbox1').val( DataField );
// OR
// $('#dialog-form').find('textarea').val( DataField );
};
$("#dialog-form").dialog(grid_modal_options);
}
</script>
这篇关于而在模式框单击该按钮并没有被解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!