多视图返回第一视图

发布于 2024-09-08 08:16:35 字数 1094 浏览 8 评论 0原文

我有一个带有多视图控件的 .net 页面。在第一个“视图”中,我有一个用户需要填写的表单(数据存储在数据库中),第二个“视图”带来一条“谢谢”消息和刚刚创建的 ID。工作正常。问题是我在第二个“视图”中添加了“打印此页”链接,以便用户可以打印他们的 ID(他们还收到一封电子邮件)。但是,当他们按下第二个“视图”中的链接按钮时,它会返回到第一个“视图”。会发生什么?

这是我的代码:

<asp:MultiView id="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View id="View1" runat="server">
 fields here

  </asp:View>

 <asp:View id="View2" runat="server">

<asp:Label ID="Label1" runat="server"></asp:Label>

 <p>
 <img alt="print" style="vertical-align:middle" src="images/printing.gif" />  <asp:LinkButton ID="LinkButton1" OnClientClick="window.print();" runat="server">
   Remember to print this page</asp:LinkButton></p>


  </asp:View>
 </asp:MultiView>  

代码隐藏:

 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    InsertNew()
End Sub

Sub InsertNew()
'all code here for inserting in database then
MultiView1.SetActiveView(View2)
Label1.Text = Text here with message
End Sub

I have a .net page with a multiview control. In the first "view" I have a form users need to fill in (data is stored in database), a second "view" brings a 'thank you' message and the ID just created. It works ok. The thing is that I added a 'print this page' link in the second "view " so users can print their IDs (they also reciben an email). But when they press the linkbutton in the second "view" it retuns to the first one. What happens?

This is my code:

<asp:MultiView id="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View id="View1" runat="server">
 fields here

  </asp:View>

 <asp:View id="View2" runat="server">

<asp:Label ID="Label1" runat="server"></asp:Label>

 <p>
 <img alt="print" style="vertical-align:middle" src="images/printing.gif" />  <asp:LinkButton ID="LinkButton1" OnClientClick="window.print();" runat="server">
   Remember to print this page</asp:LinkButton></p>


  </asp:View>
 </asp:MultiView>  

Code-behind:

 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    InsertNew()
End Sub

Sub InsertNew()
'all code here for inserting in database then
MultiView1.SetActiveView(View2)
Label1.Text = Text here with message
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蝶…霜飞 2024-09-15 08:16:35

除此之外,我认为您不想在用户单击打印按钮时发回,对吗?

使客户端脚本返回 false 以防止回发。

OnClientClick =“window.print();返回错误;”

Besides everything, i don't think you want to be posting back when the user clicks the print button right?

Make the clientscript return false to prevent postback.

OnClientClick="window.print(); return false;"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文