Solved

Linkbutton server and client events

Posted on 2011-02-18
2
1,081 Views
Last Modified: 2012-08-13
csharp asp.net 4
I have a linkbutton.

On click I insert some values into a database on server but on the client side I need to open a PDF file in a new window.

How can I achieve this?

Wing
0
Comment
Question by:WingYip
  • 2
2 Comments
 
LVL 7

Expert Comment

by:JosephEricDavis
ID: 34925911
There are server side events and client side events for the linkbutton.

<asp:LinkButton runat="server" ID="lnkButton1" OnClick="ServerSideMethod" OnClientClick="ClientSideMethod" Text="Click Me"></asp:LinkButton>

On the Server side you can do any server side processing you need, and then in the OnClientClick attribute, you give it the name of the javascript function you would like to call.  Have that javascript function open your pdf in a new window.
0
 
LVL 7

Accepted Solution

by:
JosephEricDavis earned 500 total points
ID: 34925939
You can use this to help you with your javascript for opening the pdf in a new window.

http://www.pageresource.com/jscript/jwinopen.htm

Instead of an html page for the url you would just pass it the path to the PDF document you would like to have loaded into a new window.

The onclientclick event will fire before the server side event and open the pdf before the parent page refreshes.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now