Saturday, March 31, 2012

Setting Image as background

Hi,

Im trying to set an image as the background on my webpage but how do i set it up so it doesnt become tiled, i want it to strertch and fill the screen ! cheersTo stop the image from tiling you can insert the following between the <HEAD> elements of your page

<style type="text/css">
<!--
body {background-image: url(your_image_folder/your_image.jpg); background-repeat: no-repeat}
-->
</style>

This will not stretch the image though. The is no way to do this in standard HTML. An alternative is to create an enlarged image and use that as your background, or you can try using an Image control which spans the entire page and then placing all other controls on top of it, but this should be avoided if possible because it can cause headaches if a control is behind the image and it is forgotten.

hope this helps,
sivilian

setting IIS authentication methods in web.config

Does anyone know if it is possible to set IIS authentication methods
(e.g. anonymous access, basic authentication, IWA, etc) in the
web.config file?

For example, I want to remove Anonymous Access for an entire directory
in my ASP .NET project and only use Integrated Windows Authentication.

Is there some way I can configure that in the web.config file or do I
need my Infrastructure guys to make that change in IIS?

JeremyYou can't change the IIS settings, but you can set the ASP.Net forms
authentication settings for specific directories and such to use Windows
permissions instead. Check out the forms authentication portion of the .net
framework help docs.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

<jeremy.stitt@.gmail.com> wrote in message
news:1118257534.495821.291310@.g47g2000cwa.googlegr oups.com...
> Does anyone know if it is possible to set IIS authentication methods
> (e.g. anonymous access, basic authentication, IWA, etc) in the
> web.config file?
> For example, I want to remove Anonymous Access for an entire directory
> in my ASP .NET project and only use Integrated Windows Authentication.
> Is there some way I can configure that in the web.config file or do I
> need my Infrastructure guys to make that change in IIS?
> Jeremy

setting ImageUrl for images through code not working

Dear world,
I have an IMAGE control placed on my .aspx page with its ImageUrl
property not set.
In my code, i am setting it equal to something using the following
statement
img.ImageUrl = Server.MapPath ("usedIcons/AssignAccess/" +
reader["sImage"].ToString ());
where reader as the name implies is a DataReader object reading a value
from the database.
The funny part is, when I run the code in LOCALHOST mode, it works
perfectly. But it was an embarassing experience for me, when I finally
deployed on server and asked my client to try from their remote client
machine. THE IMAGE DID NOT LOAD. All such images had the usual "X" on
them.
Why does it work on LOCALHOST, but not when viewing from a remote
client?
My doubts in case it helps you to help me:
1. Is Server.MapPath the right way to do it?
2. Is there any place in the document where this code should be kept?
3. I will be shocked if the answer to this one is "yes". "IS THE
BROWSWER LOOKING FOR THE IMAGE ON THE CLIENT MACHINE RATHER THAN ON
SERVER?"
Thanks a lot...
Michelle StoneYES, the client machine is looking for the file locally, not on your server.
Server.MapPath is for working with local paths.
In this case you want a URL that points to the image, not a local path.
To verify this you can view the HTML that is sent to the browser.
(Right click on IE web page and choose View Source.)
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
<mich_stone@.yahoo.com> wrote in message
news:1102575746.137794.265530@.f14g2000cwb.googlegroups.com...
> Dear world,
> I have an IMAGE control placed on my .aspx page with its ImageUrl
> property not set.
> In my code, i am setting it equal to something using the following
> statement
> img.ImageUrl = Server.MapPath ("usedIcons/AssignAccess/" +
> reader["sImage"].ToString ());
> where reader as the name implies is a DataReader object reading a value
> from the database.
> The funny part is, when I run the code in LOCALHOST mode, it works
> perfectly. But it was an embarassing experience for me, when I finally
> deployed on server and asked my client to try from their remote client
> machine. THE IMAGE DID NOT LOAD. All such images had the usual "X" on
> them.
> Why does it work on LOCALHOST, but not when viewing from a remote
> client?
> My doubts in case it helps you to help me:
> 1. Is Server.MapPath the right way to do it?
> 2. Is there any place in the document where this code should be kept?
> 3. I will be shocked if the answer to this one is "yes". "IS THE
> BROWSWER LOOKING FOR THE IMAGE ON THE CLIENT MACHINE RATHER THAN ON
> SERVER?"
> Thanks a lot...
> Michelle Stone
>
When you view the images from the remote host right click on the
missing image (where the "X" is) and select properties. This will tell
you where the path is getting resolved to... From this information
you will probably see the error...
More importantly you should not be using MapPath at all to set the
ImageUrl property. MapPath is used to find a Physical Path on the hard
drive for a file... That means the path is resolving to something like
c:\inetpub\wwwroot\myweb\images....etc... not good!
Just set the ImageUrl like:
img.ImageUrl = "usedIcons/AssignAccess" + reader["sImage"].ToString ());

setting ImageUrl for images through code not working

Dear world,

I have an IMAGE control placed on my .aspx page with its ImageUrl
property not set.

In my code, i am setting it equal to something using the following
statement

img.ImageUrl = Server.MapPath ("usedIcons/AssignAccess/" +
reader["sImage"].ToString ());

where reader as the name implies is a DataReader object reading a value
from the database.

The funny part is, when I run the code in LOCALHOST mode, it works
perfectly. But it was an embarassing experience for me, when I finally
deployed on server and asked my client to try from their remote client
machine. THE IMAGE DID NOT LOAD. All such images had the usual "X" on
them.

Why does it work on LOCALHOST, but not when viewing from a remote
client?

My doubts in case it helps you to help me:
1. Is Server.MapPath the right way to do it?
2. Is there any place in the document where this code should be kept?
3. I will be shocked if the answer to this one is "yes". "IS THE
BROWSWER LOOKING FOR THE IMAGE ON THE CLIENT MACHINE RATHER THAN ON
SERVER?"

Thanks a lot...

Michelle StoneYES, the client machine is looking for the file locally, not on your server.
Server.MapPath is for working with local paths.
In this case you want a URL that points to the image, not a local path.

To verify this you can view the HTML that is sent to the browser.
(Right click on IE web page and choose View Source.)

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

<mich_stone@.yahoo.com> wrote in message
news:1102575746.137794.265530@.f14g2000cwb.googlegr oups.com...
> Dear world,
> I have an IMAGE control placed on my .aspx page with its ImageUrl
> property not set.
> In my code, i am setting it equal to something using the following
> statement
> img.ImageUrl = Server.MapPath ("usedIcons/AssignAccess/" +
> reader["sImage"].ToString ());
> where reader as the name implies is a DataReader object reading a value
> from the database.
> The funny part is, when I run the code in LOCALHOST mode, it works
> perfectly. But it was an embarassing experience for me, when I finally
> deployed on server and asked my client to try from their remote client
> machine. THE IMAGE DID NOT LOAD. All such images had the usual "X" on
> them.
> Why does it work on LOCALHOST, but not when viewing from a remote
> client?
> My doubts in case it helps you to help me:
> 1. Is Server.MapPath the right way to do it?
> 2. Is there any place in the document where this code should be kept?
> 3. I will be shocked if the answer to this one is "yes". "IS THE
> BROWSWER LOOKING FOR THE IMAGE ON THE CLIENT MACHINE RATHER THAN ON
> SERVER?"
> Thanks a lot...
> Michelle Stone
When you view the images from the remote host right click on the
missing image (where the "X" is) and select properties. This will tell
you where the path is getting resolved to... From this information
you will probably see the error...

More importantly you should not be using MapPath at all to set the
ImageUrl property. MapPath is used to find a Physical Path on the hard
drive for a file... That means the path is resolving to something like
c:\inetpub\wwwroot\myweb\images....etc... not good!

Just set the ImageUrl like:
img.ImageUrl = "usedIcons/AssignAccess" + reader["sImage"].ToString ());

Setting ImageUrl for Image on Master Page

Hi,

I have a master page which includes a header, a navigation system and a ContentPlacHolder.

In the header is an <asp:Image> which I have exposed via a property, and I need to (optionally) set it's ImageUrl per each content page that uses the master.

So far, just to learn the concept, I've successfully set the ImageUrl via code in a few content pages:

this.Master.MasterImage.ImageUrl ="images/image01.jpg"

Eventually, I'll have many pages, so I would like to automate this process. Maybe look up the image in a database or something ...

Is there a way/place (maybe some global event or something?) to place some code (I can make the code) that runs every time each content page is loaded? Also, can I specify that itonly happens if the content page has a specific master page?

I'm just trying to make it so that others wont have to add the above line of code to each new content page that is made in the future. If others are adding content pages, they don't need to access the code-behind. All they will need to do is define the url in a database or something.

I'm using the ASP 2 beta, so maybe it has something new?

Thanks!

Hello.
well, i was tempted to suggest the creation of a custom master page that would add that line on the load event of the page but if you try that you'll have a dependency problem.
here's my suggestion:
create a new aspx file which doesn't have any controls on it. comething like this:

<%@.PageLanguage="C#" %>
<%@.ReferenceControl="~/MasterPage.master" %>
<scriptrunat="server">
protectedoverridevoid OnLoad(EventArgs args )
{
if (this.Master !=null )
{
if (this.Masteris ASP.MasterPage_master )
{
//your code here
}
}
}
</script>

Then you could build all your pages by inherting from that 1st aspx page. something like this:

<%@.ReferencePage="~/Default3.aspx" %>
<%@.PageLanguage="C#"Inherits="ASP.Default3_aspx"MasterPageFile="~/MasterPage.master"Debug="true" %>
<asp:Contentrunat="server"ContentPlaceHolderID="ContentPlaceHolder1"ID="p">
safsdf
</asp:Content>

This is the best I can think of. You still have to add the @.Reference tag to all your pages but you won't have to write any code for setting the master property.

Setting initial focus to a textbox when the page loads.

I can do this by using:
document.Form1.MyTextBox.focus();
However, if the page is displayed inside a modal dialog box, IE Only, then the Javascript errors.
Modal popups are an IE things, and do not work in firefox, and thus only IE has this problem.
WokaI have no idea what you mean by the page being displayed in "a modal dialog box".

I give focus using a javascript that is run on page load. It's always worked for me, and i only use IE.

Setting Initial Focus on a Text Box

How do i set the focus on a Textbox upon initial display of the page?<body onLoad="control.focus();"
>--Original Message--
>How do i set the focus on a Textbox upon initial display
of the page?