Wednesday, 15 August 2012

c# - printing a page after checking validator -



c# - printing a page after checking validator -

i want on button click check first validator print command executed here aspx code:

<asp:content id="content1" contentplaceholderid="headcontent" runat="server"> <style type="text/css"> .style1 { } @media print { .header, .style1, .footer,.hide { display:none } } </style> </asp:content> <asp:content id="content2" contentplaceholderid="maincontent" runat="server"> <asp:textbox id="textbox1" runat="server"></asp:textbox> <asp:requiredfieldvalidator id="requiredfieldvalidator1" runat="server" controltovalidate="textbox1" errormessage="requiredfieldvalidator" style="color: #ff0000"></asp:requiredfieldvalidator> <br /> <asp:button id="button1" runat="server" text="button" onclientclick="window.print();" /> </asp:content>

problem when click on button execute print function , dont check validator.

the javascript onclientclick fire before page validated. seek validating page before printing it.

function validate() { if(page_clientvalidate()) window.print(); }

then phone call so.

<asp:button id="button1" runat="server" text="button" onclientclick="validate();" />

c# asp.net

No comments:

Post a Comment