Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 31st, 2007, 02:56 PM
Registered User
Join Date: Jun 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can I use the operator ~ in Client Elements

I need to use the operator ~ in client elements like is used in asp.net server controls.
By example :
1)Writing javascript code: parent.location.href('~/Pages/Test.aspx');

I was using Request.ApplicationPath but not worked.

Thanks for your help.

Old March 31st, 2007, 04:30 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

The tilde only works on the server side. One way I have do it is to make a global javascript variable in the page that gets set with the application root by the server... something like this:

RegisterStartupScript(string.Format("<script language=\"javascript\">var _strAppRoot=\"{0}\";</script>", ResolveUrl("~"));

That should put this on the page:

<script language="javascript">var _strAppRoot="/MyApplicationName";</script>

You can then use that global var anywhere in your script to resolve a page or resource path on the client.

Old March 31st, 2007, 05:24 PM
Registered User
Join Date: Jun 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Dear Peter,

The Microsoft documentation sometimes is difficult to find alternatives options.
By example: I was seeking the ~ asp.net operator and doesn’t have any link alternative documentation to find ResolveClientUrl or ResolveUrl.

Thanks a lot!

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use like operator thillaiarasu SQL Server 2000 4 April 23rd, 2010 09:47 AM
connecting client to client (Socket programming) maricar C# 0 September 25th, 2008 04:34 AM
=== operator in c# surendraparashar C# 2005 8 November 8th, 2007 05:14 AM
Invalid operator for data type. Operator equals di Pusstiu SQL Server 2000 2 August 10th, 2007 04:51 AM
How can I use the operator ~ in Client Elements gonzalogn ASP.NET 1.0 and 1.1 Basics 0 March 31st, 2007 02:55 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.