我已经使用带有一些文本框的bootstrap创建了弹出窗口。这个弹出窗口显示在我的html按钮上。我将在页面加载时创建多个Asp按钮。我将尝试在将一些值检索到文本后每个asp按钮单击弹出窗口中的框。
我尝试在弹出窗口显示后点击每个asp按钮。但是,不检索value.so,我有一个想法我的asp按钮点击后自动点击我的HTML按钮。我可以做到这一点。请帮助我。关注我的代码。
我的HTML按钮
<button id="btn2" type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Create New</button>
<form id="form1" runat="server" class="table table-striped " cellspacing="0" width="100%">
<button id="btn2" type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Create New</button>
<asp:Table ID="Table1"
runat="server"
class="table table-striped table-bordered" cellspacing="0" width="100%"
>
<asp:TableHeaderRow runat="server" >
<asp:TableHeaderCell>Code</asp:TableHeaderCell>
<asp:TableHeaderCell>Name</asp:TableHeaderCell>
<asp:TableHeaderCell>Descrption</asp:TableHeaderCell>
<asp:TableHeaderCell>Sort</asp:TableHeaderCell>
<asp:TableHeaderCell>Enable</asp:TableHeaderCell>
<asp:TableHeaderCell>Action</asp:TableHeaderCell>
</asp:TableHeaderRow>
</asp:Table>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add New Branch </h4>
</div>
<div class="modal-body">
<%-- <p>Some text in the modal.</p>--%>
<div class="span3">
<div class="field">
<label for="firstname">Code:</label>
<asp:TextBox ID="txt_BranchCode" value="" placeholder="Branch Code" runat="server" ></asp:TextBox>
</div> <!-- /field -->
<div class="field">
<label for="lastname">Name:</label>
<asp:TextBox ID="txt_BranchName" value="" placeholder="Branch Name" runat="server" ></asp:TextBox>
</div> <!-- /field -->
<div class="field">
<label for="email">Description:</label>
<asp:TextBox ID="txt_Descr" value="" placeholder="Description" runat="server" Height="68px" TextMode="MultiLine"></asp:TextBox>
</div> <!-- /field -->
<div class="field">
<label for="password">Sort:</label>
<asp:TextBox ID="txt_Sort" value="" placeholder="Sort" runat="server"></asp:TextBox>
</div> <!-- /field -->
<div class="field">
<label for="confirm_password">Enable:</label>
<asp:DropDownList ID="dd_Enable" runat="server" Width="160px">
<asp:ListItem>True</asp:ListItem>
<asp:ListItem>False</asp:ListItem>
</asp:DropDownList>
</div> <!-- /field -->
<div class="login-actions">
<asp:Button ID="btn_Add" class="button btn btn-primary btn-large" runat="server" Text="Add" OnClick="btn_Add_Click" />
</div> <!-- .actions -->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</form>
protected void Page_Load(object sender, EventArgs e)
{
RetrieveAzureAsync(sender,e);
}
async private void RetrieveAzureAsync(object sender, EventArgs e)
{
IMobileServiceTable<BranchList> BranchTable = client.GetTable<BranchList>();
List<BranchList> items_list = await BranchTable
.Where(branchitem => branchitem.Enable == true)
.ToListAsync();
int size = items_list.Count();
if (size > 0)
{
for (int i = 0; i < size; i++)
{
TableRow row = new TableRow();
TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TableCell cell4 = new TableCell();
TableCell cell5 = new TableCell();
TableCell cell6 = new TableCell();
cell1.Text = items_list[i].BranchCode;
cell2.Text = items_list[i].BranchName;
cell3.Text = items_list[i].Descr;
cell4.Text = Convert.ToString(items_list[i].Sort);
cell5.Text = Convert.ToString(items_list[i].Enable);
//my multiple asp button
Button btn = new Button();
btn.Text = "Edit";
btn.ID = items_list[i].Id;
btn.Width = 70;
btn.CssClass = "btn btn-info btn-lg";
btn.Click += new EventHandler(btn_Click);
cell6.Controls.Add(btn);
row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3);
row.Cells.Add(cell4);
row.Cells.Add(cell5);
row.Cells.Add(cell6);
Table1.Rows.Add(row);
}
}
}
void btn_Click(object sender, EventArgs e)
{
//what code for click btn2 programmatically
}
答案 0 :(得分:1)
我现在使用简单的方式。我使用jQuery
引用此方http://jsfiddle.net/Au9tc/605/。谢谢重播所有。
答案 1 :(得分:0)
在客户端
<script>
function btnclick()
{
$("#btn2").trigger("click");
}
</script>
在服务端
void btn_Click(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "btnclick", "btnclick()", true);
}