-
Opening a new window using onclientclick event
Dear all,
I have a button in my .aspx that successfully opens a pdf document in a new window using the following button:
<asp:button id="btnReporte"
text="Reporte"
onclientclick="Navigate('.\\documentos\\83_15.pdf')"
runat="server" />
and the following javascript function:
<script type="text/javascript">
function Navigate(sRuta)
{
javascript:window.open(sRuta);
}
</script>
As you can see the .pdf name is hardcoded. I need to make it a variable, which value is known when I load the .aspx containing the button control...
Any tip on how I can accomplish that?
Thank you in advance for your interest!
mc
-
This is how I solved it:
I inserted a hidden field in my .aspx page:
<asp:HiddenField ID="hfRutaReporte1" runat="server" />
Then in the pageload event I fill the value of this field using the value stored in a Session variable:
Me.hfRutaReporte1.Value = Session("DocPath").ToString
Finally, I read the content of the hidden field in my onclientcick event:
<asp:button id="btnReporte1"
text="Reporte"
onclientclick="Navigate(document.form1.item('hfRutaReporte1').value)"
runat="server" />
If anyone is interested in the full code, please let me know and I will be happy to share an example.
Thank you all!
mc
-
I found a simpler, more elegant way to do the same without hidden fields.
I just define the onclientclick event in my page load event:
Me.btnReporte1.OnClientClick = "Navigate('" & Session("DocPath").ToString & "')"
Hope this helps. If anyone needs more details I'll be happy to help.
mc
Similar Threads
-
By Usha.R in forum ASP.NET
Replies: 1
Last Post: 02-14-2006, 03:30 AM
-
Replies: 146
Last Post: 08-12-2002, 10:40 PM
-
By Rob Teixeira in forum .NET
Replies: 129
Last Post: 06-06-2002, 05:23 AM
-
By TC in forum VB Classic
Replies: 8
Last Post: 09-26-2000, 02:34 AM
-
By TC in forum VB Classic
Replies: 0
Last Post: 09-25-2000, 09:06 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks