这是我嵌入 javascript 的 ascx 页面。
当视图更改时,我想突出显示包含在 div 标记(用于测试目的的 div2)中的视图。
截至目前,观点变化良好,但我无法让亮点发挥作用。
我的javascript有问题还是我错过了其他东西?
谢谢
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<p>This is View 1</p>
<asp:Button ID="Button1" runat="server" Text="Next" onclick="Button1_Click" />
</asp:View>
<asp:View ID="View2" runat="server">
<div id="div2" style="height:auto; width:auto;">
<p>This is View 2</p>
<asp:Button ID="Button2" runat="server" Text="Previous"
onclick="Button2_Click" />
<asp:Button ID="Button3" runat="server" Text="Next" onclick="Button3_Click" />
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#Button1").click(function () {
$("#div2").effect("highlight", {}, 3000);
});
});
</script>
</asp:View>
<asp:View ID="View3" runat="server">
<p>This is View 3</p>
<asp:Button ID="Button4" runat="server" Text="Previous"
onclick="Button4_Click1" />
</asp:View>
</asp:MultiView>
</ContentTemplate>
</asp:UpdatePanel>
代码背后:
namespace Multiview1.Multiview1
{
public partial class Multiview1UserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
MultiView1.SetActiveView(View1);
}
protected void Button1_Click(object sender, EventArgs e)
{
MultiView1.SetActiveView(View2);
UpdatePanel1.Update();
}
protected void Button3_Click(object sender, EventArgs e)
{
MultiView1.SetActiveView(View3);
UpdatePanel1.Update();
}
protected void Button2_Click(object sender, EventArgs e)
{
MultiView1.SetActiveView(View1);
UpdatePanel1.Update();
}
protected void Button4_Click1(object sender, EventArgs e)
{
MultiView1.SetActiveView(View2);
UpdatePanel1.Update();
}
}
}