Tuesday, 17 September 2013

How to Hide Buttons On Hardcopy of Printed Page and also Hide URL and Date

To hide URL and date in hard copy of printed page you should do some setting in your browsers as it's setting changes according to various browsers. First look at Firefox so do it according to this.

Go> Page setup> Select Margin & Header footer and make all field blank according to your requirment.
In Chrome after giving print command do following
If you want to hide buttons on printed page then in you javascript code you should hide all buttons after giving print command so do it as
 <script type="text/javascript">
        function printpage() {
            var a = document.getElementById("Button1");
            var b = document.getElementById("Button2");
            a.style.visibility = 'hidden';
            b.style.visibility = 'hidden';
            window.print()
        }
</script>
And in your button give command like this..
<asp:Button class="button" ID="Button1" runat="server" Height="33px" Text="Print"
                        Width="117px" OnClientClick="printpage()"  />

In the above javascript code Button2 is extra button in my page that's why it is in the code.

hope this will help ..

Pass Value From One Web Page To Another in Asp.Net

Suppose there is a scenario in which you want when you click on some text then associated value should pass to another page and with the help of this associated value you can do anything. That link my be simply in paragraph or in Grid View or in Data list.
There may be many methods to do it and I hope one of them called 'Session' be in you knowledge. But doing this with help of session is not considered good so here we will use other technique as well..
Suppose you have Page 'a.aspx' and other page 'b.aspx' you want to pass value from one to another then on first page write this code but before this suppose you have a link button on click of this associated value will pass to 'b.aspx'.
code on click event of link button in 'a.aspx'

Response.Redirect("b.aspx?value=" + here you should write variable of reference variable);
Response.Redirect("b.aspx");

on the page 'b.aspx' of page load event write following code (you can take this value in variable in the form of string.

string passedvalue= Request.QueryString["value"];
here value will carry the assigned value from one page to another. But if you are using Grid View and have link and want to display associated data on other page. Then you will have to use OnRowCommand="shashi_RowCommand" event of Grid View and corresponding command name property of link button so that various link button associated with Grid View can perform various tasks.
In my example.

here i have two link buttons in my grid view that's why used two command name so that they can perform various task associated with them. You will have to give command name in link button. see this image.