473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Changing URL string before inserting with C#

Hello, I'm new member, Please someone help me..

I got image's address using Server.MapPath and returned it to .ImageURL of the ImageButton but it didn't work
I noticed later that if I added \\\ 3 backslashs "as a string" at the bigining of the address it would work properly, so is there anyway to add backslash to a STRING in C#, because the compiler doesn't accept any backslash in "\\\" string formats
Or how could we edit string properly before we insert it into address
and what is the exact format of ImageURL strings
Mar 13 '07 #1
12 2377
Page.Response.Redirect(@"Dir1\Dir2\Mypage.aspx")
or
Page.Response.Redirect("Dir1\\Dir2\\Mypage.aspx")
Mar 13 '07 #2
Thank you very much for your answer, but I mean Image URL not the page's one
I used "C:\dir1\dir2\image.jpg"
but it didn't work, so I tried "\\\C:\dir1\dir2\image.jpg"
it worked..!!!!

Anyway, if I can edit the text after retriving it by using Server.MapPath, it would give me more flexibility...
Mar 13 '07 #3
Please someone helps me... I'm still waiting!!
Mar 14 '07 #4
protected void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Image1.ImageUrl = Server.MapPath("..\\Images\\BankName.JPEG");
}

I did this way and it is working. Please tell me if I am misinterpreting the question.
Mar 15 '07 #5
Thanks for you reply, but I would let you know what exactly I'm trying to do..

I have directory which contains all images I'm automating displaying them, by searching for them and returning them in an array to present them on my webpage
here is the code



int i = 0;
// get the address of the directory, then seach for files with .JPG extension inside
string add = Server.MapPath("pics//horses//");
string[] images = Directory.GetFiles(add , "*.jpg");

// Create ImageButton Array, and use it to store & present result images in determine specifications
ImageButton[] imageBtt = new ImageButton[images.Length];
foreach (string image in images)
{
Label1.Text += image;
imageBtt[i] = new ImageButton();
imageBtt[i].Width = 70;
imageBtt[i].Height = 47;
imageBtt[i].ID = "imageBtt" + i;
imageBtt[i].Visible = true;
imageBtt[i].ImageUrl = image;

ContentPlaceHolder3.Controls.Add(imageBtt[i]);
i++;
}


I used Lable1 to know exactly what is the address returning by this code, its correct as it's shown below:

C:\Documents and Settings\showroom\My Documents\Visual Studio 2005\HorseClub\pics\horses\cebit.jpg

but it's not showing the images by the ImageButtons, I'm wondering if it's because of the address format. What do you think??
Mar 15 '07 #6
One simple (may be silly as well) question.
Can you modify the below line
string add = Server.MapPath("pics//horses//");
as
string add = Server.MapPath("pics\\horses\\");

and see what happens?
:)
Mar 15 '07 #7
Sorry :-(
it gave the same results...
Mar 15 '07 #8
but you know!!? such a format like this worked with ImageURL address:

\\\C:\Documents and Settings\showroom\My Documents\Visual Studio 2005\HorseClub\pics\horses\cebit.jpg

but I tried to add "\\\" to the begining of the address before inserting it into ImageURL but it didn't work, maybe the compiler rejects such a character \ as a string...
Mar 15 '07 #9
Please someone gives more attention to my request, it very close to be solved...
Mar 17 '07 #10
Isn't there anyway to insert \ backslash into string with C#
This is the second community which stoped responding at this point
Mar 19 '07 #11
string[] imgs = Directory.GetFiles("E:\\Projects\\Banking\\Images" , "*.jpg");
foreach (string img in imgs)
ImageButton1.ImageUrl = img ;

The above code is working fine.... I am not able to reproduce your problem.
Mar 20 '07 #12
SammyB
807 Expert 512MB
Isn't there anyway to insert \ backslash into string with C#
This is the second community which stoped responding at this point
But, we didn't stop responding! ;o)

There are two ways to insert a backslash:
  1. As Avkdsiva did, you use two backslashes
  2. But, that gets messy: if you have three backslashes, you have to use six. So, if you place an @ before the first quote, then you can place backslashes in the string:
Expand|Select|Wrap|Line Numbers
  1. MessageBox.Show(@"\\\C:\Documents and Settings\showroom\My Documents\Visual Studio 2005\HorseClub\pics\horses\cebit.jpg");
Mar 20 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Danny Anderson | last post by:
Hola! I am working on a program where I am including a library that came with my numerical methods textbook. The "util.h" simply includes a large number of files. I had to change the util.h...
5
by: MaSTeR | last post by:
Can anyone provide a practical short example of why in C# I shouldn't compare two strings with == ? If I write this in JAVA String string1 = "Widget"; if (string1 == "Widget") ...
7
by: .Net Sports | last post by:
Before processing my data in a datagrid, I need to parse the day of the week (which will be my 'rqsday' variable) from a string that comes over on a querystring: string rqs =...
0
by: mannux | last post by:
doing a multilingual site, i have strings in an sql database encoded in their respective codePage for use in an html page (ie for korean, strings are encoded using the euc-kr charset) i have to...
9
by: jy836 | last post by:
I was using VB .NET, working on my database application. After running it successfully, I decided to take a little break. So I closed Visual Studio (I saved all files, of course), and when I opened...
1
by: Ken Fine | last post by:
I'm using ASP VB. I want to insert a VbCr or a VbLf into a declared string every N characters. FWIW, I want to do this because of an apparent limitation in MSXML2, which I am using to "scrape" data...
7
by: Matt | last post by:
I am attempting to reformat a string, inserting newlines before certain phrases. For example, in formatting SQL, I want to start a new line at each JOIN condition. Noting that strings are...
4
by: yaru22 | last post by:
Hi, I'm relatively new to C programming and was quite confused by this error. What I tried to do is that if I have a string with double quotes around it (i.e. char *str = "\"hello\"";), I have...
2
by: samonline | last post by:
Dear friends, I have written a little program to read the source of a web page into a Rich Text Box. Now I want to find a specific integer value in that text box and take it into a variable. That...
3
by: =?Utf-8?B?ZGVlcGFr?= | last post by:
Hi All, How to convert the 1st format of string to 2nd one in vb.net 1st(datetype string) : "2/12/2008 6:00:00 PM" 2nd(datatype string): "2008-2-12T17:00:00" note: in 2nd string ,the T is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.