Title: declare a string rather than address
Tags: c#;asp.net;ftp
Question: ```alt="" src="ftp://+1-838-486-8450/Chrysanthemum.jpg" 
        style="height: 299px; width: 317px"
```

how do I declare a string rather than address for ftp? i would like to say 

```alt="" src="imagePath" 
        style="height: 299px; width: 317px"
```

how would I declare that in my actual c# aspx.cs code? And in this code above?


Here is the accepted answer: If you mean you want to use the value of a string variable as the ```src``` attribute, then you will want to do something like this:

```alt="" src="<%= Server.HTMLEncode(someStringVariable) %&gt;" ...
```

Or if you are on ASP.NET 4:

```alt="" src="<%: someStringVariable %&gt;" ...
```

Comment for this answer: compiler error photopath does not exist in the current context?
Comment for this answer: `{

            string PhotoPath;

            GridViewRow row = GridView1.Rows[GridView1.SelectedIndex];

            PhotoPath = row.Cells[5].Text;

        }`
Comment for this answer: protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
Comment for this answer: yup done and done you sir are are awesome! Thanks so much for the help my god lucky I didnt go with my previous coding should have seen it ;)
Comment for this answer: @Garrith: Now that you've managed to get this to work, you can use the same code to point to an ASHX, without giving the client your FTP password.
Comment for this answer: @Garrith: Then the variable does not exist in the context of the page.  It must either be (1) previously declared in the page, or (2) declared as a field/property in the page's codebehind file.  If you are referencing a static field/property on another class, you will have to qualify it with the class name.  Pasting the code where you declare this variable would help.
Comment for this answer: @Garrith: If that is a method definition, then the `PhotoPath` variable is in a different scope entirely from the page.  You will have to promote that variable to a class-level variable (a field) if you want this to work.  Note that the field will need to be public or protected for it to be accessible from the page markup file.
Comment for this answer: @Garrith: Well, promoting the variable to a class-level field should require no other code changes at all, since the names would be identical.  However, this will have to be a design decision that you make based on the structure of your page.
Comment for this answer: @Garrith: You can only place a bounty on a question if it's been open for a day or so with no accepted answer.  Don't worry about it -- I'm here primarily to help, not garner rep points.

Here is another answer: ```alt="" src="<%=imagePath%&gt;" 
        style="height: 299px; width: 317px"
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:12/06/10', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<c#><asp.net><ftp>', 'Title': 'declare a string rather than address', 'ViewCount': 71, 'id': 4363556, 'user_AboutMe': '<p>New to C# and Matlab, enjoy learning via questions which makes stackoverflow my adopted home!</p>\n', 'user_AccountId': 220019.0, 'user_DisplayName': 'G Gr', 'user_Reputation': 5880.0, 'user_Views': 1214.0, 'user_id': 477228.0}}