views:

43

answers:

1

Hi,

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
+1  A: 

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;"

Jeroen
oops, should've known that! Many thanks!
netNewbi3