Hot to get a value in aspx page from Web.Config file?
-
Hi there, I've created a web page and it contains three images. These all images will be changable. So i want to give the path of images in Web.Config file and file name in that particular image src. How i can give that?. Also am using code behind not inline. I wanted to write only in aspx page not in codebehind. Below is my code: Web.Config:
<add key="ImagePath" value="http://192.168.0.181/Labeling/Images/"/>
and in my aspx page,<img id="ImgHeader" runat="server" src="<%header.gif%>" />
What all the ways available to call WebConfig file values? Please help..!!Regards n Thks Sam.M
<img id="ImgHeader" runat="server" src='<% ConfigurationManager.AppSettings["ImgHeader"] %>' />
?
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
Hi there, I've created a web page and it contains three images. These all images will be changable. So i want to give the path of images in Web.Config file and file name in that particular image src. How i can give that?. Also am using code behind not inline. I wanted to write only in aspx page not in codebehind. Below is my code: Web.Config:
<add key="ImagePath" value="http://192.168.0.181/Labeling/Images/"/>
and in my aspx page,<img id="ImgHeader" runat="server" src="<%header.gif%>" />
What all the ways available to call WebConfig file values? Please help..!!Regards n Thks Sam.M
string strConfig= System.Configuration.ConfigurationSettings.AppSettings[strKey];
Best Regards ----------------- Abhijit Jana "Success is Journey it's not a destination"
modified on Tuesday, May 6, 2008 9:13 AM
-
string strConfig= System.Configuration.ConfigurationSettings.AppSettings[strKey];
Best Regards ----------------- Abhijit Jana "Success is Journey it's not a destination"
modified on Tuesday, May 6, 2008 9:13 AM
Abhijit Jana wrote:
string strConfig= System.Configuration.ConfigurationSettings.AppSettings[strKey]; strFilePath = HttpContext.Current.Server.MapPath(strConfig); now read it as XML file
:confused: What do you mean ? What is the point in reading as XML file for setting a image URL ?
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
Abhijit Jana wrote:
string strConfig= System.Configuration.ConfigurationSettings.AppSettings[strKey]; strFilePath = HttpContext.Current.Server.MapPath(strConfig); now read it as XML file
:confused: What do you mean ? What is the point in reading as XML file for setting a image URL ?
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
<img id="ImgHeader" runat="server" src='<% ConfigurationManager.AppSettings["ImgHeader"] %>' />
?
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
Sorry. This is not working. It's not retrieving the value from web.Config file. When i right click the image and see the properties it says "Not Available" I want to write the path only in aspx page and all other code i've written in code behind. Do i need to register any namespace?
Regards n Thks Sam.M
-
Sorry. This is not working. It's not retrieving the value from web.Config file. When i right click the image and see the properties it says "Not Available" I want to write the path only in aspx page and all other code i've written in code behind. Do i need to register any namespace?
Regards n Thks Sam.M
Then try
<img id="ImgHeader" src='<%= ConfigurationManager.AppSettings["ImagePath"] %>' />
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
Then try
<img id="ImgHeader" src='<%= ConfigurationManager.AppSettings["ImagePath"] %>' />
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
I tried,but below error is coming: Compiler Error Message: CS1002: ; expected
Regards n Thks Sam.M
Yes you need to put
;
at the end of statement.<img id="ImgHeader" src='<%= ConfigurationManager.AppSettings["ImagePath"]; %>' />
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
Yes you need to put
;
at the end of statement.<img id="ImgHeader" src='<%= ConfigurationManager.AppSettings["ImagePath"]; %>' />
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
This is not working. I want to write the path only in aspx page and all other code i've written in code behind. Do i need to register any namespace?
Regards n Thks Sam.M
If your images are all going to be assigned via code behind and you have access to the control: imgHeader.ImageUrl = ConfigurationManager.AppSettings["ImgHeader"] + "image.jpg"; or, if your going to use a mixture of code behind and UI, ]]>' /> I think you might be duplicating your assignment of the src value, thus overwritting what is initially set loosing the path.