Escape An Ampersand In A Path String?

Nov 8, 2010

I need to be able to navigate through the file system from an asp.net page and gather metadata on files, directories ... The simple code I've put together makes a list of directories/files in a given location and has everything displayed as a link button. My problem is with link buttons under which I have paths that include ampersands and blanks. Here's a sample of code:

[Code]....

The Response.Redirect("aPage.aspx?d="+ e.CommandArgument.ToString()); line has the problem ... the e.CommandArgument.ToString() shows a truncated path that stops just before the first ampersand detected. I tried escaping the ampersand with a backslash but it did not work ... somehow I guess it's not exactly the character that's causing the problem ..

View 3 Replies


Similar Messages:

Ampersand Escape Character Doesn't Work On Impersonation Password

Jun 23, 2010

I'm trying to connect to my sql server 2008 database and I'm using impersonation within my asp.net 3.5 application

<identity impersonate="true" userName="testUserName" password="test&test" />

Naturally the compiler won't compile until I use the escape character:

<identity impersonate="true" userName="testUserName" password="test&test" />

So it compiles, unfortunately when I run my app, it get this:

Parser Error Message: Could not create Windows user token from the credentials specified in the config file. Error from the operating system 'Logon failure: unknown user name or bad password.

Source Error:

<identity impersonate="true" userName="testUserName" password="test&test" />

View 1 Replies

Don't Want To Escape String From Database

Oct 28, 2010

I have a field with product name

abc® product1

If I get the data from the database and databind it to the dropdownlist. It becomes

<option value="2">abc &reg; product1</option>

I don't want ASP.net to escape the ® to %amp;reg.

View 3 Replies

C# - How To Include Ampersand In Connection String Password After Using Entity Framework

Sep 29, 2010

I'm using Entity Framework 4 for a simple app and would like to bake my connection credentials into the following connection string:

<connectionStrings>
<add name="MyEntities"
connectionString="metadata=res://*/MyDataModel.csdl|res://*/MyDataModel.ssdl|res://*/MyDataModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=localhostDEV;Initial Catalog=MyDB;UserId=myUser;Password=jack&jill;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
</connectionStrings>

However, the password (which I cannot change) contains an ampersand. ASP.NET throws:
Configuration Error: An error occurred while parsing EntityName. Line XX, position YYY.

If I replace the ampersand in the password with &, I get a SqlException: Login failed for user 'myUser'. Usually this trick works, but I'm guessing that something is failing because this is technically a connection string inside a connection string.

What should I do here? Most of my classes include code like:

using (var context = new MyEntities()) {
// do work
}

Update: It turns out that the credentials I am using are a domain account, so what I really need is Integrated Security=True in the connection string rather than a password.

Encoding the ampersand as indicated in the accepted answer should work fine, though I haven't tested it.

View 3 Replies

What Is The Escape Sequence For & In String Literals In Web.config

Feb 2, 2011

What is the escape sequence for &-sign in string literals in web.config?

View 2 Replies

Databinding - Escape Double Quotes In Asp Onclick String

Jul 10, 2010

I am trying to insert dynamic data into a onclick property for a control the code looks like this

onclick="openRadWindow('<%#Eval("ID";) %>','<%#Eval("ParentObjectID") %>');"

I cant get it to fire and the trouble seems to be the double quotes, what is the correct method on escaping the quotes so that this fires.

View 4 Replies

SQL Server :: Unrecognized Escape Sequence In Connection String?

Sep 25, 2010

In my program, I want to make database connectivity, but when i write a connection string, complier says that it is unrecognized escape sequence(which is bolded in the following string), the string is :

Data Source=HIMANSHUSQLEXPRESS;Initial Catalog=Himanshu;Integrated Security=True

View 3 Replies

Access Path Denied - Is There Any Format To Set The Path As String

Feb 13, 2010

I had applied the following code as said by you :

byte[] b = YourByteArrayFromDb;
File.WriteAllBytes(MyFilePath, b);

But I am receiving an exception "Access to the path is denied". How do I solve this using ASP.Net with C#? And is there any format to set the path as string?

View 3 Replies

How To ESCAPE "comma" In Javascript Error / Unterminated String Constant

Feb 14, 2011

EDIT1:

btnDelete.Attributes.Add("onclick", String.Format(@"return DeleteRow('{0}',{1},{2},{3});", e.Row.ClientID, e.Row.RowIndex, DataBinder.Eval(e.Row.DataItem, "Id"), "'" + DataBinder.Eval(e.Row.DataItem, "Name") + "'"));

edit:

i get this error:

Message: Unterminated string constant

i am passing the value from code behind and some of my text have somethinh lke this:

[code]....

View 3 Replies

Save Local File Path As String And Open File From Saved String?

Jan 29, 2011

I have a form where users can store some data for archived documents. All documents are ONLY in PDF format.

There are 2 things I would like to do:

1. there is a "file path" text box on the form. I would like to open a "browse file dialog" box when user clicks the textbox and then the user browses for the file (file is on the users local machine) and selects it. The full file path should be saved to the textbox as string (e.g. "c:archive2010document11122011.pdf"). Also I would like to "limit" the file browser dialog to only show PDF format files...

2. add a code behind command to open the file from the saved path+name (see 1.) in the user's default PDF viewer (Acrobat or Foxit)

View 11 Replies

C# - Handle Query String In Site Map Path?

Jan 3, 2011

i am having a condition in which i have to pass the query string in the URL, the page which i am calling contains the Site map path control.

But as i pass the query string with the URL, the site map path is not working.

how can i handle query string in site mat path control as i have web.sitemap file containing the nodes

Edited : my url is like http://localhost:1400/RevenueAccounting/Auth/BillingAdministration/RackHireDueDetails.aspx?t=1&LiableRoad=BNSF

having 2 varables in query string, the first variable will remain same always but the value of second variable changes the actual error is, when i am using just the URL

http://localhost:1400/RevenueAccounting/Auth/BillingAdministration/RackHireDueDetails.aspx?t=1

in web.sitemap then the site map is not showing on page, and the value of second variable changes so how could i use site map path for this condition

View 1 Replies

Web Forms :: Get Treeview Selected Path As A String?

Dec 5, 2010

I'm dynamically generating a tree view on the folder structure on client machine:

C:
-- Folder 1
-- Folder 2
D:
-- Folder 1
--- Folder 11
--- Folder 12
-- Folder 2
etc...

When the user expands and select - say folder 12, I want to get the path as D:/Folder1/Folder12 in to a string

then when the user changes the selection to D:/Folder1 i want to get that path in the string.

View 2 Replies

Ampersand In URL Of RSS Feed

Jan 14, 2011

As part of our app, user can save some data as XML on server which becomes RSS feed for them. Now some of the file user created have & in file name as BB&T_RSS.xml. So when user point this to [URL], they won't get his. I tried BB%26T.xml, BB&T.xml without any success with IE, Chrome

View 2 Replies

ADO.NET :: Find Connection String Path In Three Tier Architecture?

Jul 27, 2010

How to find connection string path in three tier architecture?

View 3 Replies

How To Put An Ampersand In The Dropdownlist Text

Dec 13, 2010

i want to put this text



in the text of a dropdownlistitem, so at runtime it will show the euro sign

but .net nicely escapes my code, and then it becomes this:

&euro;

and that will show in my dropdownlist, and that's not what i want.

Any other way to show € Ł etc in a dropdownlist is accepted too.

code:

private void FillDropDownCurrency(DropDownList ddl)
{
ddl.Items.Add(new ListItem() { Value = CurrencyConstants.CHF_CURRENCY_CODE, Text = CurrencyConstants.CHF_CURRENCY_SYMBOL, Selected = false });
ddl.Items.Add(new ListItem() { Value = CurrencyConstants.GBP_CURRENCY_CODE, Text = CurrencyConstants.GBP_CURRENCY_SYMBOL, Selected = false });
ddl.Items.Add(new ListItem() { Value = CurrencyConstants.EURO_CURRENCY_CODE, Text = CurrencyConstants.EURO_CURRENCY_SYMBOL, Selected = true });
ddl.Items.Add(new ListItem() { Value = CurrencyConstants.USD_CURRENCY_CODE, Text = CurrencyConstants.USD_CURRENCY_SYMBOL, Selected = false });
}
The CurrencyConstants.EURO_CURRENCY_SYMBOL is the € code

View 2 Replies

Preserve Ampersand In URL's Querystring When Using RegisterClientScriptInclude?

Sep 1, 2010

I have the need to add a javascript include to my ASP.NET page. The url of the javascript file has two key/value pairs in the query string. But the ampersand is being escaped and I don't want that.

Page.ClientScript.RegisterClientScriptInclude("myKey",
"https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1")
This results in the following HTML:
<script
src="https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"
type="text/javascript"></script>
But what I really want is:
<script
src="https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"
type="text/javascript"></script>

View 1 Replies

Javascript - Inject A Script URL Containing An Ampersand?

Feb 3, 2010

I have a server control that needs to programmatically inject a JavaScript reference into the page. It is to reference Microsoft's Bing map control which requires &s=1 to be appended to the script URL for use over SSL. The problem is that the .NET Framework encodes the attributes and changes the & to an & (verified with Reflector). At some point after that the & is removed altogether.

Desired script tag:
<script type="text/javascript"
src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1">
</script>
Attempt 1:
var clientScriptManager = this.Page.ClientScript;
if (!clientScriptManager.IsClientScriptIncludeRegistered(this.GetType(), "BingMapControl"))
{
clientScriptManager.RegisterClientScriptInclude(
this.GetType(), "BingMapControl",
"https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1");
}
Attempt 2:
HtmlGenericControl include = new HtmlGenericControl("script");
include.Attributes.Add("type", "text/javascript");
include.Attributes.Add("src",
"https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1");
this.Page.Header.Controls.Add(include);

View 3 Replies

HttpHandlers / Modules :: Ampersand In URL = Bad Request

Feb 24, 2010

If I have an & in the URL I get a bad request. I have followed the instructions at [URL] but still no luck. If I remove

[Code]....

from web.config it works. Encoding the URL does not help.

View 7 Replies

Querystring Format To Deal With Ampersand(&)

Mar 17, 2010

I use the following string format to navigate between webpages:

String.Format(Eval("Hyper") + "?BUSINESSSTREAM={0}&Dealer={1}&LeadID={2}&Companyid={3}&SalesPerson={4}", Eval("BusinessStream"), Eval("Dealer"),Eval("leadId"),Eval("CompanyID"),Eval("SalesPerson"))

However the companyid is a text string and the company may have an "&" in it which I know will truncate the string. I have seen that this can be overcome by using "UrlEncode" [URL] However I cant solve the syntax.

View 10 Replies

Search For Name Containing Ampersand In Google Places API

Aug 11, 2014

I'm using the Google Places API to discover information on a restaurant. [URL] ....

I need my name parameter to contain an & because I am looking for D'Agostino's Pizza & Pub. But I am not sure what my URL needs to look like, because my requests are returning no matches. I am trying:

maps.googleapis.com/maps/api/place/nearbysearch/json?location=41.8957646,-87.6553512&radius=5000&types=restaurant|food&name=D'Agostino's Pizza %26 Pub&key=<mykey>. But is that even right?

I believe the search should return results, because in google if you type "D'Agostino's restaurant north ogden avenue Chicago IL", it's a perfect match there.

View 5 Replies

Passing Ampersand Character In Querystring

Jul 24, 2012

1. How to read a query string if the data contains a '&' in it.

E.g.:

Default.aspx?id=1275&msg=abc&cba

after reading the query string 

id = 1275

msg = abc&cba

View 1 Replies

Passing Folder Path String To Web Service Function Via JQuery.ajax?

Apr 24, 2010

I need to perform asp.net web-service function call via jQuery and pass asp.net application path to it. That's the way I'm trying to do it (code is located within asp.net page, e.g. aspx file):

[code]...

Function call works well, but applicationPath parameter doesn't passed correctly. When I debug it I see that backslashes are removed, function gets "C:ProjectsSamplesmytestwebsite" instead of "'C:ProjectsSamplesmytestwebsite'".

View 2 Replies

Databases :: How To Construct An Excel File Connection String With Full Path

Jan 14, 2011

I am trying to write a page to read the Excel file provided by the user. I know I can't use the FileUpload to get the full path of the file from the client PC. This give me the problem when I write the connection string for the Excel file:

[Code]....

Without the full path, I can't replace the Data Source by a variable and I definitely can't assume all users will have their Excel files named Book1.xls located in C:Doc all the time.

View 1 Replies

Web Forms :: Regex For Validate Email Containing Ampersand

Nov 19, 2010

I have this simple regex string to validate emails. It worked fine until someone came along with an email address that contained an ampersand:

^(['_a-zA-Z0-9-]+)(.['_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+)(.[a-zA-Z0-9-]+)*(.[a-zA-Z]{2,5})$

how I can alter this to accept the & symbol? I have tried countless ways with no success.

View 4 Replies

C# - How To Escape Eval <%

Jan 10, 2011

I have such code:

<%# (int)Eval("Favorites") > 0 ? "<a href="history.aspx?visitorid=<%# Eval("VisitorID") %">Favorites</a> / " : ""%>

where I show a link if value>0 .. However it gives me a bad url(history.aspx?visitorid=%3C%#%20Eval) when I put visitorID=<%#...%>inside another Eval<%#..%>

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved