Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Saturday, March 31, 2012

Set a separator image for a SiteMapPath (skin)

In a ASP.NET 2.0 project I'd like to set an image as path separator in
the SiteMapPath. When I edit the PathSepartor template (for this
SiteMapPath) and drag an image on it, it works fine for all pages in
the root of the Web project. VS2005 creates the folling aspx:
<asp:SiteMapPath ID="SiteMapPath" runat="server">
<PathSeparatorTemplate>
<img src="http://pics.10026.com/?src=Images/arrow-right.jpg" />
</PathSeparatorTemplate>
</asp:SiteMapPath>
However, this project also has pages in subfolders. For all pages in
these subfolers this images reference doesn't work anymore (logical
behavirour). So I changed the img src to "~/Images/arrow-right.jpg" as
shown below:
<asp:SiteMapPath ID="SiteMapPath" runat="server">
<PathSeparatorTemplate>
<img src="http://pics.10026.com/?src=~/Images/arrow-right.jpg" />
</PathSeparatorTemplate>
</asp:SiteMapPath>
This results in not showing the arrow image at all. Even not in the
pages in the root of the webproject. The image properties in the
website state: "http://localhost/project/~/Images/arrow-right.jpg".
Other options I tried where "../" and "./". None of them seem to work.
Does somebody has a solution to this problem? Is it a bug?
Kind regards,
Jules
BTW: The behaviour as described above also occurs when I set this
SiteMap style in a .skin file in the App_Thems.Mark your <img> with runat=server
-Brock
http://staff.develop.com/ballen

> In a ASP.NET 2.0 project I'd like to set an image as path separator in
> the SiteMapPath. When I edit the PathSepartor template (for this
> SiteMapPath) and drag an image on it, it works fine for all pages in
> the root of the Web project. VS2005 creates the folling aspx:
> <asp:SiteMapPath ID="SiteMapPath" runat="server">
> <PathSeparatorTemplate>
> <img src="http://pics.10026.com/?src=Images/arrow-right.jpg" />
> </PathSeparatorTemplate>
> </asp:SiteMapPath>
> However, this project also has pages in subfolders. For all pages in
> these subfolers this images reference doesn't work anymore (logical
> behavirour). So I changed the img src to "~/Images/arrow-right.jpg" as
> shown below:
> <asp:SiteMapPath ID="SiteMapPath" runat="server">
> <PathSeparatorTemplate>
> <img src="http://pics.10026.com/?src=~/Images/arrow-right.jpg" />
> </PathSeparatorTemplate>
> </asp:SiteMapPath>
> This results in not showing the arrow image at all. Even not in the
> pages in the root of the webproject. The image properties in the
> website state: "http://localhost/project/~/Images/arrow-right.jpg".
> Other options I tried where "../" and "./". None of them seem to work.
> Does somebody has a solution to this problem? Is it a bug?
> Kind regards,
> Jules
> BTW: The behaviour as described above also occurs when I set this
> SiteMap style in a .skin file in the App_Thems.
>

Set a separator image for a SiteMapPath (skin)

In a ASP.NET 2.0 project I'd like to set an image as path separator in
the SiteMapPath. When I edit the PathSepartor template (for this
SiteMapPath) and drag an image on it, it works fine for all pages in
the root of the Web project. VS2005 creates the folling aspx:

<asp:SiteMapPath ID="SiteMapPath" runat="server">
<PathSeparatorTemplate>
<img src="http://pics.10026.com/?src=Images/arrow-right.jpg" />
</PathSeparatorTemplate>
</asp:SiteMapPath
However, this project also has pages in subfolders. For all pages in
these subfolers this images reference doesn't work anymore (logical
behavirour). So I changed the img src to "~/Images/arrow-right.jpg" as
shown below:

<asp:SiteMapPath ID="SiteMapPath" runat="server">
<PathSeparatorTemplate>
<img src="http://pics.10026.com/?src=~/Images/arrow-right.jpg" />
</PathSeparatorTemplate>
</asp:SiteMapPath
This results in not showing the arrow image at all. Even not in the
pages in the root of the webproject. The image properties in the
website state: "http://localhost/project/~/Images/arrow-right.jpg".
Other options I tried where "../" and "./". None of them seem to work.
Does somebody has a solution to this problem? Is it a bug?

Kind regards,

Jules

BTW: The behaviour as described above also occurs when I set this
SiteMap style in a .skin file in the App_Thems.Mark your <img> with runat=server

-Brock
http://staff.develop.com/ballen

> In a ASP.NET 2.0 project I'd like to set an image as path separator in
> the SiteMapPath. When I edit the PathSepartor template (for this
> SiteMapPath) and drag an image on it, it works fine for all pages in
> the root of the Web project. VS2005 creates the folling aspx:
> <asp:SiteMapPath ID="SiteMapPath" runat="server">
> <PathSeparatorTemplate>
> <img src="http://pics.10026.com/?src=Images/arrow-right.jpg" />
> </PathSeparatorTemplate>
> </asp:SiteMapPath>
> However, this project also has pages in subfolders. For all pages in
> these subfolers this images reference doesn't work anymore (logical
> behavirour). So I changed the img src to "~/Images/arrow-right.jpg" as
> shown below:
> <asp:SiteMapPath ID="SiteMapPath" runat="server">
> <PathSeparatorTemplate>
> <img src="http://pics.10026.com/?src=~/Images/arrow-right.jpg" />
> </PathSeparatorTemplate>
> </asp:SiteMapPath>
> This results in not showing the arrow image at all. Even not in the
> pages in the root of the webproject. The image properties in the
> website state: "http://localhost/project/~/Images/arrow-right.jpg".
> Other options I tried where "../" and "./". None of them seem to work.
> Does somebody has a solution to this problem? Is it a bug?
> Kind regards,
> Jules
> BTW: The behaviour as described above also occurs when I set this
> SiteMap style in a .skin file in the App_Thems.

Set alternate text to empty string

Hi,

I have found that with both the HtmlImage and the Image that if I set the AlternateText property to string.Empty then the 'alt' tag is omitted from the output img tag.

Is there a way around this? The accessibility checkers demand an alt tag even if its empty. If this is not possible, does anyone know if there's much difference between an lt tag set to empty string and an alt tag set to a single space?

Cheers, WT.

the only real difference between setting an alt tag to " " rather than haveing it string.empty is that if left empty it will take it off the form so that .net does not have to keep up with that tag. It's the same thing if you set it to visible = False it just doen't show up on the form. so ultimately it comes down to speed (an almost imeasurable amount). My suggestion is to leave it with one single space.


Ahh, well actually " " results in a dodgy tool tip being displayed! Adding the 'alt' attribute with 'Control.Attributes.Add()' apears to allow empty string alt tags though.


string.empty return a NULL, and a single space is actually an instance of string. they are totally different.
if you assign string.empty to thebase.Attributes["alt"](as shown below), then that "alt" atrribute is actually set to NULL. so, in the render function, it would not be generated to html code. while for a single space, it's not null but an
reference to an realy object, so, "alt" will get rendered. For information i suggest you to look up the .net "control","htmlcontrol" nd "htmlImg" source code. :)
 
public string Alt{get {string text =base.Attributes["alt"];if (text ==null) {return string.Empty; }return text; }set {base.Attributes["alt"] = HtmlControl.MapStringAttributeToString(value); }}

string.Emptyis an instance of a string. Directly setting Attributes["alt"] to string.Empty results in an empty alt tag instead of no alt tag. It must be 'HtmlControl.MapStringAttributeToString' that's returning null when passed string.Empty.


agree. 
internalstaticstringMapStringAttributeToString(string s){if ((s !=null) && (s.Length ==0)) {returnnull; }returns;}
string.Empty is actually an object of string type.

publicstaticreadonlystringEmpty;

the code above is copied fromReflector.Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information.

set ASP.NET datagrid image based on SQL table value

I have an ASP.NET datagrid that loads an image. I would like to load
one image if the value in my SQL table is true and another if it is
false. Here is my code.
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false"
Codebehind="Search.aspx.vb" Inherits="PROJECT.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="VBScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="MyGrid" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px" runat="server"
BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
BackColor="#DEBA84" CellPadding="3"
AutoGenerateColumns="False" CellSpacing="2">
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#738A9C"></SelectedItemStyle>
<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#A55129"></HeaderStyle>
<FooterStyle ForeColor="#8C4510"
BackColor="#F7DFB5"></FooterStyle>
<Columns>
</asp:BoundColumn>
<asp:BoundColumn DataField="City" ReadOnly="True" HeaderText="City">
<ItemStyle Width="150px"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Check or X">
<ItemTemplate>
<img src='\Check.gif'>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#8C4510"
Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
</form>
</body>
</HTML>
I want to show the 'Check.gif' if an SQL table value is True or
'x.gif' if it is false.
Thaks for any help, This ASP.NET is kicking my butt.Hi Rob,
Just jam a little
<IMG src='<%#iif(DataBinder.Eval(Container,
"DataItem.Boolean"),"Check.gif","x.gif") %>'>
in there and you should be okay.
BTW, I had some problems with your markup. My fixed version is below.
Does this help?
Ken
Microsoft MVP [ASP.NET]
Toronto
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="VBScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="MyGrid" runat="server" BorderColor="#DEBA84"
BorderStyle="None" BorderWidth="1px"
BackColor="#DEBA84" CellPadding="3" AutoGenerateColumns="False"
CellSpacing="2">
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#738A9C"></SelectedItemStyle>
<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#A55129"></HeaderStyle>
<FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="City" ReadOnly="True" HeaderText="City">
<ItemStyle Width="150px"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Check or X">
<ItemTemplate>
<IMG src='<%#iif(DataBinder.Eval(Container,
"DataItem.Boolean"),"Check.gif","x.gif") %>'>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#8C4510"
Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
</form>
</body>
</HTML>
"Rob Rogers" <rob@.natltc.com> wrote in message
news:7ee34208.0407141234.18d2abdd@.posting.google.com...
>I have an ASP.NET datagrid that loads an image. I would like to load
> one image if the value in my SQL table is true and another if it is
> false. Here is my code.
> <%@. Page Language="vb" AutoEventWireup="false"
> Codebehind="Search.aspx.vb" Inherits="PROJECT.WebForm1"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name="vs_defaultClientScript" content="VBScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout">
> <form id="Form1" method="post" runat="server">
> <asp:DataGrid id="MyGrid" style="Z-INDEX: 101; LEFT: 0px; POSITION:
> absolute; TOP: 0px" runat="server"
> BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
> BackColor="#DEBA84" CellPadding="3"
> AutoGenerateColumns="False" CellSpacing="2">
> <SelectedItemStyle Font-Bold="True" ForeColor="White"
> BackColor="#738A9C"></SelectedItemStyle>
> <ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
> <HeaderStyle Font-Bold="True" ForeColor="White"
> BackColor="#A55129"></HeaderStyle>
> <FooterStyle ForeColor="#8C4510"
> BackColor="#F7DFB5"></FooterStyle>
> <Columns>
> </asp:BoundColumn>
> <asp:BoundColumn DataField="City" ReadOnly="True" HeaderText="City">
> <ItemStyle Width="150px"></ItemStyle>
> </asp:BoundColumn>
> <asp:TemplateColumn HeaderText="Check or X">
> <ItemTemplate>
> <img src='\Check.gif'>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> </Columns>
> <PagerStyle HorizontalAlign="Center" ForeColor="#8C4510"
> Mode="NumericPages"></PagerStyle>
> </asp:DataGrid>
> </form>
> </body>
> </HTML>
> I want to show the 'Check.gif' if an SQL table value is True or
> 'x.gif' if it is false.
> Thaks for any help, This ASP.NET is kicking my butt.
BTW, here's the code behind and data source that I used for that example.
"Boolean" is the name of the field as well as the type.
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
MyGrid.DataSource = CreateDataSource()
MyGrid.DataBind()
End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("City", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource
"Rob Rogers" <rob@.natltc.com> wrote in message
news:7ee34208.0407141234.18d2abdd@.posting.google.com...
>I have an ASP.NET datagrid that loads an image. I would like to load
> one image if the value in my SQL table is true and another if it is
> false. Here is my code.
> <%@. Page Language="vb" AutoEventWireup="false"
> Codebehind="Search.aspx.vb" Inherits="PROJECT.WebForm1"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name="vs_defaultClientScript" content="VBScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout">
> <form id="Form1" method="post" runat="server">
> <asp:DataGrid id="MyGrid" style="Z-INDEX: 101; LEFT: 0px; POSITION:
> absolute; TOP: 0px" runat="server"
> BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
> BackColor="#DEBA84" CellPadding="3"
> AutoGenerateColumns="False" CellSpacing="2">
> <SelectedItemStyle Font-Bold="True" ForeColor="White"
> BackColor="#738A9C"></SelectedItemStyle>
> <ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
> <HeaderStyle Font-Bold="True" ForeColor="White"
> BackColor="#A55129"></HeaderStyle>
> <FooterStyle ForeColor="#8C4510"
> BackColor="#F7DFB5"></FooterStyle>
> <Columns>
> </asp:BoundColumn>
> <asp:BoundColumn DataField="City" ReadOnly="True" HeaderText="City">
> <ItemStyle Width="150px"></ItemStyle>
> </asp:BoundColumn>
> <asp:TemplateColumn HeaderText="Check or X">
> <ItemTemplate>
> <img src='\Check.gif'>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> </Columns>
> <PagerStyle HorizontalAlign="Center" ForeColor="#8C4510"
> Mode="NumericPages"></PagerStyle>
> </asp:DataGrid>
> </form>
> </body>
> </HTML>
> I want to show the 'Check.gif' if an SQL table value is True or
> 'x.gif' if it is false.
> Thaks for any help, This ASP.NET is kicking my butt.
Thanks, Thats just what I needed.
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

set ASP.NET datagrid image based on SQL table value

I have an ASP.NET datagrid that loads an image. I would like to load
one image if the value in my SQL table is true and another if it is
false. Here is my code.

<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false"
Codebehind="Search.aspx.vb" Inherits="PROJECT.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="VBScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="MyGrid" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px" runat="server"
BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
BackColor="#DEBA84" CellPadding="3"
AutoGenerateColumns="False" CellSpacing="2">
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#738A9C"></SelectedItemStyle>
<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#A55129"></HeaderStyle>
<FooterStyle ForeColor="#8C4510"
BackColor="#F7DFB5"></FooterStyle>
<Columns>
</asp:BoundColumn>
<asp:BoundColumn DataField="City" ReadOnly="True" HeaderText="City">
<ItemStyle Width="150px"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Check or X">
<ItemTemplate>
<img src='\Check.gif'>
</ItemTemplate>
</asp:TemplateColumn
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#8C4510"
Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
</form>
</body>
</HTML
I want to show the 'Check.gif' if an SQL table value is True or
'x.gif' if it is false.

Thaks for any help, This ASP.NET is kicking my butt.Hi Rob,

Just jam a little

<IMG src='<%#iif(DataBinder.Eval(Container,
"DataItem.Boolean"),"Check.gif","x.gif") %>'
in there and you should be okay.

BTW, I had some problems with your markup. My fixed version is below.

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="VBScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="MyGrid" runat="server" BorderColor="#DEBA84"
BorderStyle="None" BorderWidth="1px"
BackColor="#DEBA84" CellPadding="3" AutoGenerateColumns="False"
CellSpacing="2">
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#738A9C"></SelectedItemStyle>
<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#A55129"></HeaderStyle>
<FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="City" ReadOnly="True" HeaderText="City">
<ItemStyle Width="150px"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Check or X">
<ItemTemplate>
<IMG src='<%#iif(DataBinder.Eval(Container,
"DataItem.Boolean"),"Check.gif","x.gif") %>'>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#8C4510"
Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
</form>
</body>
</HTML
"Rob Rogers" <rob@.natltc.com> wrote in message
news:7ee34208.0407141234.18d2abdd@.posting.google.c om...
>I have an ASP.NET datagrid that loads an image. I would like to load
> one image if the value in my SQL table is true and another if it is
> false. Here is my code.
> <%@. Page Language="vb" AutoEventWireup="false"
> Codebehind="Search.aspx.vb" Inherits="PROJECT.WebForm1"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name="vs_defaultClientScript" content="VBScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout">
> <form id="Form1" method="post" runat="server">
> <asp:DataGrid id="MyGrid" style="Z-INDEX: 101; LEFT: 0px; POSITION:
> absolute; TOP: 0px" runat="server"
> BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
> BackColor="#DEBA84" CellPadding="3"
> AutoGenerateColumns="False" CellSpacing="2">
> <SelectedItemStyle Font-Bold="True" ForeColor="White"
> BackColor="#738A9C"></SelectedItemStyle>
> <ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
> <HeaderStyle Font-Bold="True" ForeColor="White"
> BackColor="#A55129"></HeaderStyle>
> <FooterStyle ForeColor="#8C4510"
> BackColor="#F7DFB5"></FooterStyle>
> <Columns>
> </asp:BoundColumn>
> <asp:BoundColumn DataField="City" ReadOnly="True" HeaderText="City">
> <ItemStyle Width="150px"></ItemStyle>
> </asp:BoundColumn>
> <asp:TemplateColumn HeaderText="Check or X">
> <ItemTemplate>
> <img src='\Check.gif'>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> </Columns>
> <PagerStyle HorizontalAlign="Center" ForeColor="#8C4510"
> Mode="NumericPages"></PagerStyle>
> </asp:DataGrid>
> </form>
> </body>
> </HTML>
> I want to show the 'Check.gif' if an SQL table value is True or
> 'x.gif' if it is false.
> Thaks for any help, This ASP.NET is kicking my butt.
BTW, here's the code behind and data source that I used for that example.
"Boolean" is the name of the field as well as the type.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
MyGrid.DataSource = CreateDataSource()
MyGrid.DataBind()

End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("City", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

"Rob Rogers" <rob@.natltc.com> wrote in message
news:7ee34208.0407141234.18d2abdd@.posting.google.c om...
>I have an ASP.NET datagrid that loads an image. I would like to load
> one image if the value in my SQL table is true and another if it is
> false. Here is my code.
> <%@. Page Language="vb" AutoEventWireup="false"
> Codebehind="Search.aspx.vb" Inherits="PROJECT.WebForm1"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name="vs_defaultClientScript" content="VBScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout">
> <form id="Form1" method="post" runat="server">
> <asp:DataGrid id="MyGrid" style="Z-INDEX: 101; LEFT: 0px; POSITION:
> absolute; TOP: 0px" runat="server"
> BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
> BackColor="#DEBA84" CellPadding="3"
> AutoGenerateColumns="False" CellSpacing="2">
> <SelectedItemStyle Font-Bold="True" ForeColor="White"
> BackColor="#738A9C"></SelectedItemStyle>
> <ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
> <HeaderStyle Font-Bold="True" ForeColor="White"
> BackColor="#A55129"></HeaderStyle>
> <FooterStyle ForeColor="#8C4510"
> BackColor="#F7DFB5"></FooterStyle>
> <Columns>
> </asp:BoundColumn>
> <asp:BoundColumn DataField="City" ReadOnly="True" HeaderText="City">
> <ItemStyle Width="150px"></ItemStyle>
> </asp:BoundColumn>
> <asp:TemplateColumn HeaderText="Check or X">
> <ItemTemplate>
> <img src='\Check.gif'>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> </Columns>
> <PagerStyle HorizontalAlign="Center" ForeColor="#8C4510"
> Mode="NumericPages"></PagerStyle>
> </asp:DataGrid>
> </form>
> </body>
> </HTML>
> I want to show the 'Check.gif' if an SQL table value is True or
> 'x.gif' if it is false.
> Thaks for any help, This ASP.NET is kicking my butt.
Thanks, Thats just what I needed.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Set bit depth of an image

Hi. I haven't been able to get an answer in the vb newsgroup on the topic,
so I'll try here. I'm converting .tif images into other image formats like
..jpeg and .gif and I need to know how I can control the bit depth of these
images. The System.Drawing.Image object's default bit depth when saving
images seems to be 24 for .jpeg and 8 for .gif.

Thanks,
Shawnuse CxImage library, better than .nets...

http://www.aoi.it/download.html

"Shawn" <bossman100@.hotmail.com> wrote in message
news:%23c8isWgQDHA.2212@.TK2MSFTNGP12.phx.gbl...
> Hi. I haven't been able to get an answer in the vb newsgroup on the
topic,
> so I'll try here. I'm converting .tif images into other image formats
like
> .jpeg and .gif and I need to know how I can control the bit depth of these
> images. The System.Drawing.Image object's default bit depth when saving
> images seems to be 24 for .jpeg and 8 for .gif.
> Thanks,
> Shawn

Monday, March 26, 2012

Set file name returned from ASP.NET page by URL

Hi!
I have an .aspx page which returns an image. This page takes some GET
parameters, so URL looks like this:
http://localhost/page.aspx?id=1234
Now, when the user click this link, I want that his browser would receive
picture with some good looking name, like image1.jpg.
How to do this within ASP.NET code ?..

--
Pawe
www.DATAX.plWrite an HTTPHandler. Using the Handler, you can make a request for an image
file and get back whatever the handler returns. For example,

http://localhost/image1.jpg?id=1234

would return an image named "image1.jpg" - which could be anything you
generate via your Handler.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"pawel" <pawel.zarzycki@.interia.pl> wrote in message
news:#1SMC4B7DHA.1040@.TK2MSFTNGP10.phx.gbl...
> Hi!
> I have an .aspx page which returns an image. This page takes some GET
> parameters, so URL looks like this:
> http://localhost/page.aspx?id=1234
> Now, when the user click this link, I want that his browser would receive
> picture with some good looking name, like image1.jpg.
> How to do this within ASP.NET code ?..
> --
> Pawe
> www.DATAX.pl
Thanks for the answer.
Can you shortly tell me what exactly is that HTTPHandler ?.. I cant find
such topic in MSDN.
Paul

"Kevin Spencer" <kevin@.takempis.com> wrote in message
news:%23PRm1$B7DHA.2764@.TK2MSFTNGP09.phx.gbl...
> Write an HTTPHandler. Using the Handler, you can make a request for an
image
> file and get back whatever the handler returns. For example,
> http://localhost/image1.jpg?id=1234
> would return an image named "image1.jpg" - which could be anything you
> generate via your Handler.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
> "pawel" <pawel.zarzycki@.interia.pl> wrote in message
> news:#1SMC4B7DHA.1040@.TK2MSFTNGP10.phx.gbl...
> > Hi!
> > I have an .aspx page which returns an image. This page takes some GET
> > parameters, so URL looks like this:
> > http://localhost/page.aspx?id=1234
> > Now, when the user click this link, I want that his browser would
receive
> > picture with some good looking name, like image1.jpg.
> > How to do this within ASP.NET code ?..
> > --
> > Pawe
> > www.DATAX.pl
You might try something like this:

Response.Clear();
Response.AddHeader("Content-Disposition","inline;filename=image1.jpg");
Response.WriteFile("myfile.jpg");

Here's more info:
http://msdn.microsoft.com/library/d...tefiletopic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"pawel" <pawel.zarzycki@.interia.pl> wrote in message
news:%231SMC4B7DHA.1040@.TK2MSFTNGP10.phx.gbl...
> Hi!
> I have an .aspx page which returns an image. This page takes some GET
> parameters, so URL looks like this:
> http://localhost/page.aspx?id=1234
> Now, when the user click this link, I want that his browser would receive
> picture with some good looking name, like image1.jpg.
> How to do this within ASP.NET code ?..
> --
> Pawe
> www.DATAX.pl
Sure. An HttpHandler is a class that handles HTTP requests. In ASP.Net a
Page class, for example, is the default HttpHandler for files with a .aspx
extension. You can map different file extensions to different HttpHandlers
in ASP.Net. What happens is, when the web server receives a request for a
file, it looks in its configuration to find out whether a special
HttpHandler has been designated for that file extension. ASP.Net provides
the HttpHandler class to extend the functionality of ASP.net to be able to
handle requests for other file types (extensions). In IIS, you make ASP.Net
the HttpHandler for the type of file that you desire, and use the web.config
file for your web to identify what DLL (Class Library) is used to handle
specific file extensions.

The HttpHandler is a clsss that handles the request. It has access to the
same HttpContext (Request, Response, Cookies, Session, Application, Server,
etc) that the Page class does.

For more detailed information, see:

http://msdn.microsoft.com/library/d...ttphandlers.asp

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"pawel" <pawel.zarzycki@.interia.pl> wrote in message
news:uLuTwUC7DHA.1052@.TK2MSFTNGP12.phx.gbl...
> Thanks for the answer.
> Can you shortly tell me what exactly is that HTTPHandler ?.. I cant find
> such topic in MSDN.
> Paul
> "Kevin Spencer" <kevin@.takempis.com> wrote in message
> news:%23PRm1$B7DHA.2764@.TK2MSFTNGP09.phx.gbl...
> > Write an HTTPHandler. Using the Handler, you can make a request for an
> image
> > file and get back whatever the handler returns. For example,
> > http://localhost/image1.jpg?id=1234
> > would return an image named "image1.jpg" - which could be anything you
> > generate via your Handler.
> > --
> > HTH,
> > Kevin Spencer
> > .Net Developer
> > Microsoft MVP
> > Big things are made up
> > of lots of little things.
> > "pawel" <pawel.zarzycki@.interia.pl> wrote in message
> > news:#1SMC4B7DHA.1040@.TK2MSFTNGP10.phx.gbl...
> > > Hi!
> > > I have an .aspx page which returns an image. This page takes some GET
> > > parameters, so URL looks like this:
> > > http://localhost/page.aspx?id=1234
> > > Now, when the user click this link, I want that his browser would
> receive
> > > picture with some good looking name, like image1.jpg.
> > > How to do this within ASP.NET code ?..
> > > > --
> > > Pawe
> > > www.DATAX.pl
> >

Thursday, March 22, 2012

set image url programmatically for image control

I have a print page that uses an image control to display an image that is saved in a directory that is dynamically created upon a session start. I have the path readily available for the image control...but I am failing to get the image to display in the image control...

what is the syntax to properly set the url for an image control programmatically in the code behind?

the control is named printImage

thanks in advance

Eric

printImage.src=


printImage.ImageUrl = "your URL";

simple as that.


I am not getting the .src in intellisense for the control - is there a namespace/directive that I am missing?


ekeefauver:

I am not getting the .src in intellisense for the control - is there a namespace/directive that I am missing?

Nope, it's just, that property is called "ImageUrl" and not "src".


doesn't seem to work for me...do I somehow need to refresh the control after setting the URL to the image?

the path to the image is: C:\Documents and Settings\dekeefau\My Documents\Visual Studio 2005\WebSites\CMAT_FINAL\sessions\sd_ewwewtjwy23b5vnrmxm1mffz\print\theimage.bmp

which is stored in a string variable


No, there is no need to refresh the control. Perhaps the path you are using is not valid? Try using Server.MapPath() function with the relative path to the image in question.

Example:

Image is in the /Images subfolder of the application and its name is MyImage.gif

Then the code to display this image would be:

printImage.ImageUrl = Server.MapPath("~/Images/MyImage.gif");

Set Image Control to Bitmap

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image they
can not see the full size. If I can create a bitmap from the stream I know
the size so I can set the properties of a image control and then display the
bitmap in the image. Does this make since or am I going about this the
wrong way? So in a nutshell, I am pulling images from a DB and want to
display the full size without having to actuall save the image to a file.
Any pointers?
TIAYou can make an mypage.aspx page that returns bitmap (not HTML)
1. You need to set ContentType = "img/gif"; or (jpg)
2. You need to set ContentLength to the size of the image
3. Use Response.BinaryWrite to output the image. Or since Response is a
Stream you can do Bitmap.Save(Response);
in your HTML you write <img src="http://pics.10026.com/?src=mypage.aspx">
PS: It's more efficient to use handler for that task. mypage.ashx. But aspx
will work too if you fill more comfortable with aspx.
George.
"MikeB" <m@.nospam.com> wrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...
> Hello All, want to be able to pull images from the database and load them
> into a bitmap through a stream which I have working. I then want to take
> the bitmap and load it into a Image control without haveing to save the
> bitmap as a file. Is this possible? Currently, I just display the bitmap
> by calling Bitmap.save however, if users do not know to click the image
> they can not see the full size. If I can create a bitmap from the stream
> I know the size so I can set the properties of a image control and then
> display the bitmap in the image. Does this make since or am I going about
> this the wrong way? So in a nutshell, I am pulling images from a DB and
> want to display the full size without having to actuall save the image to
> a file. Any pointers?
> TIA
>
Here is a way to do this without relying on an external handler such as
another page:
http://www.eggheadcafe.com/articles/20050911.asp
-Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"MikeB" wrote:

> Hello All, want to be able to pull images from the database and load them
> into a bitmap through a stream which I have working. I then want to take
> the bitmap and load it into a Image control without haveing to save the
> bitmap as a file. Is this possible? Currently, I just display the bitmap
> by calling Bitmap.save however, if users do not know to click the image th
ey
> can not see the full size. If I can create a bitmap from the stream I kno
w
> the size so I can set the properties of a image control and then display t
he
> bitmap in the image. Does this make since or am I going about this the
> wrong way? So in a nutshell, I am pulling images from a DB and want to
> display the full size without having to actuall save the image to a file.
> Any pointers?
> TIA
>
>
Your page can have an Image control on it, and that Image control can point
to another page (or handler) that retrieves the image.
Here are the details:
http://SteveOrr.net/articles/ImproveYourImages.aspx
http://dotnetslackers.com/articles/...FileDenial.aspx
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"MikeB" <m@.nospam.com> wrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...
> Hello All, want to be able to pull images from the database and load them
> into a bitmap through a stream which I have working. I then want to take
> the bitmap and load it into a Image control without haveing to save the
> bitmap as a file. Is this possible? Currently, I just display the bitmap
> by calling Bitmap.save however, if users do not know to click the image
> they can not see the full size. If I can create a bitmap from the stream
> I know the size so I can set the properties of a image control and then
> display the bitmap in the image. Does this make since or am I going about
> this the wrong way? So in a nutshell, I am pulling images from a DB and
> want to display the full size without having to actuall save the image to
> a file. Any pointers?
> TIA
>
Thanks everyone for the replies.
"MikeB" <m@.nospam.com> wrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...
> Hello All, want to be able to pull images from the database and load them
> into a bitmap through a stream which I have working. I then want to take
> the bitmap and load it into a Image control without haveing to save the
> bitmap as a file. Is this possible? Currently, I just display the bitmap
> by calling Bitmap.save however, if users do not know to click the image
> they can not see the full size. If I can create a bitmap from the stream
> I know the size so I can set the properties of a image control and then
> display the bitmap in the image. Does this make since or am I going about
> this the wrong way? So in a nutshell, I am pulling images from a DB and
> want to display the full size without having to actuall save the image to
> a file. Any pointers?
> TIA
>

Set Image Control to Bitmap

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image they
can not see the full size. If I can create a bitmap from the stream I know
the size so I can set the properties of a image control and then display the
bitmap in the image. Does this make since or am I going about this the
wrong way? So in a nutshell, I am pulling images from a DB and want to
display the full size without having to actuall save the image to a file.
Any pointers?

TIAYou can make an mypage.aspx page that returns bitmap (not HTML)
1. You need to set ContentType = "img/gif"; or (jpg)
2. You need to set ContentLength to the size of the image
3. Use Response.BinaryWrite to output the image. Or since Response is a
Stream you can do Bitmap.Save(Response);

in your HTML you write <img src="http://pics.10026.com/?src=mypage.aspx">

PS: It's more efficient to use handler for that task. mypage.ashx. But aspx
will work too if you fill more comfortable with aspx.

George.

"MikeB" <m@.nospam.comwrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image
they can not see the full size. If I can create a bitmap from the stream
I know the size so I can set the properties of a image control and then
display the bitmap in the image. Does this make since or am I going about
this the wrong way? So in a nutshell, I am pulling images from a DB and
want to display the full size without having to actuall save the image to
a file. Any pointers?
>
TIA
>


Here is a way to do this without relying on an external handler such as
another page:

http://www.eggheadcafe.com/articles/20050911.asp
-Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"MikeB" wrote:

Quote:

Originally Posted by

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image they
can not see the full size. If I can create a bitmap from the stream I know
the size so I can set the properties of a image control and then display the
bitmap in the image. Does this make since or am I going about this the
wrong way? So in a nutshell, I am pulling images from a DB and want to
display the full size without having to actuall save the image to a file.
Any pointers?
>
TIA
>
>
>


Your page can have an Image control on it, and that Image control can point
to another page (or handler) that retrieves the image.
Here are the details:
http://SteveOrr.net/articles/ImproveYourImages.aspx
http://dotnetslackers.com/articles/...FileDenial.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"MikeB" <m@.nospam.comwrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image
they can not see the full size. If I can create a bitmap from the stream
I know the size so I can set the properties of a image control and then
display the bitmap in the image. Does this make since or am I going about
this the wrong way? So in a nutshell, I am pulling images from a DB and
want to display the full size without having to actuall save the image to
a file. Any pointers?
>
TIA
>


Thanks everyone for the replies.

"MikeB" <m@.nospam.comwrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image
they can not see the full size. If I can create a bitmap from the stream
I know the size so I can set the properties of a image control and then
display the bitmap in the image. Does this make since or am I going about
this the wrong way? So in a nutshell, I am pulling images from a DB and
want to display the full size without having to actuall save the image to
a file. Any pointers?
>
TIA
>

Set Masterpage Image...

Hi Y'all,

I want to set an image (header) in my masterpage, i don't want to use design view because the image can change.

It works like this:

1protected void Page_Load(object sender, EventArgs e)2 {3//change the image4System.Web.UI.WebControls.Image masterImage;5masterImage = (System.Web.UI.WebControls.Image)6Master.FindControl("tssclogo");7if (masterImage !=null)8 {9 Session["masterpageurl"] ="~/img/logo.gif";10 masterImage.ImageUrl = Session["masterpageurl"].ToString();11 }12 }

But the problem is that i have to put this code in every page load of my content pages. Isn't there a way i only have to set this once?

Thanks in advance!

Why don't you use an usercontrol. Put that on the masterpage and let that handle the image...
It slipped my mind... but why not using the onload event of the masterpage itself?

that's a nice idea!

I will have to work with 2 masterpages then because the userid only gets determined after authentication.

Thanks


You can work with one. Just check in the onpageload if the user is authenticated. If not, get the default image, otherwise the non-default...