Question about window.open

  • Thread starter Thread starter Danny Ni
  • Start date Start date
D

Danny Ni

Hi,

I have a webform that will pop up window by clicking button or links
inside data grid.
Here are some sample code snippet:

'For button
btnOrder.Attributes.Add("onclick", "window.open('order.aspx?.............

'For datagrid
<asp:TemplateColumn>
<ItemTemplate>
<a href="#" onclick="window.open('Modules/AR/order.aspx.........">Order</a>
</ItemTemplate>
</asp:TemplateColumn>

In both instances I use window.open on client side to pop up new window.
The strange thing is, at some occasions I have to use Modules/AR/order.aspx
to open, at other I will have to use the file name order.aspx only without
the path.

The struture in my machine: I have a ASP.Net web application in
http://localhost/Dev. all related aspx files are located in
http://localhost/Dev/Modules/AR directory.

Right now I have to try and err every time to find out if I need to add path
to the filename.

Can somebody suggest a better way to do this? I don't think using absolute
path can resolve my problem either, becase my current application is at
http://localhost/Dev , the application could be moved to
http://someserver/Live or others.
so /dev/Modules/AR/order.aspx is no good for me either.

TIA
 
Hi Danny,

another option would be to add an entry to the Web.Config that
specifies the current path to use. It could look something like this :

<appSettings>
<!-- Test Setting -->
<add key="ActiveAppPath" value="http://localhost/Dev"/>
<!-- Live Setting -->
<!--add key="ActiveAppPath" value="http://localhost/Dev"/-->
<appSettings>

Then grab the path from the config.
Hope this helps.

Tod Birdsall
http://tod1d.blogspot.com
 
Back
Top