Solved

Linkbutton server and client events

Posted on 2011-02-18
2
1,092 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

810 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