是否可以从另一个 Web 表单中的按钮调用一个 Web 表单中的“按钮单击事件”?实际上我想要做的是,我有一个第二种形式的链接按钮,当它被点击时,我希望第一种形式显示,并且第一种形式的按钮也被点击。谁能帮我做到这一点?
问问题
620 次
2 回答
2
我假设您正在使用 jQuery 并且对它有基本的了解。所以这样做:
<form id="form1" style="display:none">
<Asp:Button id="button1" onclick="alert('clicked')" >button1</Asp:Button>
</form>
<form id="form2">
<Asp:LinkButton url="javascript:void(0);" onclick="call1();">Link button1</Asp:LinkButton>
</form>
<script>
function call1()
{
$("#form1").show();
$("#button1").trigger("click");
}
</script>
注意:我写的asp标记会出现编译错误,请自行解决。我这样说只是为了让您了解如何处理它。
于 2013-02-27T06:23:48.357 回答
0
create a Delegate in WebForms (I have used in WinForms)
public delegate void LoginDelegate(string s);
loginAirLineDelegate = new LoginDelegate(DisableToolStripMenuItems);
public void DisableToolStripMenuItems(string s)
{
this.viewToolStripMenuItem.Visible = true;
this.bookingToolStripMenuItem.Visible = true;
this.existingUserToolStripMenuItem.Visible = false;
this.newUserToolStripMenuItem.Visible = false;
this.toolStripStatusUserID.Text = "USerID :- "+s;
this.LoginUserId = s;
}
I have passed the Delaqgte to other Form with Construtor as argumnet. I can able to fire the delegate from the second form like this
logDelegate(textBoxUserName.Text);
于 2013-02-27T06:37:18.480 回答