Saturday, March 31, 2012

System.Drawing.Drawing2D.GraphicsPath in ASP.Net

Hi,
Can I use GraphicsPath class in ASP.Net page? There's other way to do this?
thanks a lotEduardo Rosa wrote:

> Hi,
> Can I use GraphicsPath class in ASP.Net page? There's other way to do this
?
> thanks a lot
>
What's your goal?
//Rutger
You can create graphic images from any .NET code.
The question then becomes "what do you do with the image?"
In ASP.NET the most obvious thing would be to point an image control to it.
MyImageControl.ImageURL="myImage.gif"
or
MyIMageContro.ImageURL="myImageGeneratorPage.aspx"
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Eduardo Rosa" <eddr5000@.yahoo.com.br> wrote in message
news:e0mB7CGkEHA.1996@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Can I use GraphicsPath class in ASP.Net page? There's other way to do
> this?
> thanks a lot
>
thanks a lot, I was just curious...

System.Drawing.Drawing2D.GraphicsPath in ASP.Net

Hi,
Can I use GraphicsPath class in ASP.Net page? There's other way to do this?

thanks a lotEduardo Rosa wrote:

> Hi,
> Can I use GraphicsPath class in ASP.Net page? There's other way to do this?
> thanks a lot

What's your goal?

//Rutger
You can create graphic images from any .NET code.
The question then becomes "what do you do with the image?"
In ASP.NET the most obvious thing would be to point an image control to it.
MyImageControl.ImageURL="myImage.gif"
or
MyIMageContro.ImageURL="myImageGeneratorPage.aspx"

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

"Eduardo Rosa" <eddr5000@.yahoo.com.br> wrote in message
news:e0mB7CGkEHA.1996@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Can I use GraphicsPath class in ASP.Net page? There's other way to do
> this?
> thanks a lot
thanks a lot, I was just curious...

System.drawing.image

Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well...

I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");

After which I can do these steps without any problem

System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);

Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);

srcImage.Dispose();

The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."

Does anyone know what I can do about these issues?Try also

graphicOrig.Dispose();

--Daniel
http://staff.newtelligence.com/danielf/

--Original Message--
From: benoit [mailto:benoit@.discussions.microsoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: System.drawing.image
Subject: System.drawing.image

Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgName".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well...

I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");

After which I can do these steps without any problem

System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);

Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality =
CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);

srcImage.Dispose();

The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(imgPath + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is
being
used by another process."

Does anyone know what I can do about these issues?
Try getting the actual path of your posted file from System.IO.Path
namespace. You can use it like this:

string FileName =
System.IO.Path.GetFileName(fileUpload.PostedFile.F ileName); // fileUpload is
the id of fileupload html control

Zeeshan
http://zishu.blogspot.com

"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.

graphicOrig.Dispose();
rectOrig.Dispose();

Zeeshan.
http://zishu.blogspot.com

"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
thanks
it worked !

"Zeeshan Muhammad" wrote:

> Sorry forgot to mention. You cannot manipulate an image at client side,
> therefore you need to save the image at server in order to resize it. And
> for the delete problem, dispose the Graphics and Rectange object that you
> have created before deleting the image.
> graphicOrig.Dispose();
> rectOrig.Dispose();
> Zeeshan.
> http://zishu.blogspot.com
> "benoit" <benoit@.discussions.microsoft.com> wrote in message
> news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> > Hi,
> > I have this question.
> > When I use the FileUpload WebControl to post an Image (= SourceFile) that
> > I
> > want to resize and write to the server, I keep getting this situation.
> > If that SourceFile is located in My Documents (as in "C:\Documents and
> > Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> > a
> > 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> > from
> > "C:\Folder\imgName".
> > What can I do about this ?
> > Actually I found a workaround, but this gives me an error as well...
> > I can save the PostedFile like this
> > PostedFile.SaveAs(imgPath + "DummyName");
> > After which I can do these steps without any problem
> > System.Drawing.Image srcImage =
> > System.Drawing.Image.FromFile(imgPath + DummyName);
> > Graphics graphicOrig = Graphics.FromImage(srcImage);
> > graphicOrig.CompositingQuality =
> > CompositingQuality.HighQuality;
> > graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> > graphicOrig.InterpolationMode =
> > InterpolationMode.HighQualityBicubic;
> > Rectangle rectOrig = new Rectangle();
> > graphicOrig.DrawImage(srcImage, rectOrig);
> > srcImage.Save(NewFileName, ImageFormat.Jpeg);
> > srcImage.Dispose();
> > The final srcImage is perfect, and everything I need but when I want to do
> > this
> > File.Delete(imgPath + dummyName);
> > I get the IOException that File cannot be deleted:
> > "The process cannot access the file 'ImgPAth\dummyName' because it is
> > being
> > used by another process."
> > Does anyone know what I can do about these issues?
>
thanks
it worked !

"Daniel Fisher(lennybacon)" wrote:

> Try also
> graphicOrig.Dispose();
>
> --Daniel
> http://staff.newtelligence.com/danielf/
>
>
> --Original Message--
> From: benoit [mailto:benoit@.discussions.microsoft.com]
> Posted At: Monday, January 23, 2006 12:21 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: System.drawing.image
> Subject: System.drawing.image
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile)
> that I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
> getting a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to
> do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>

System.drawing.image

Hi,
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."
Does anyone know what I can do about these issues?Try also
graphicOrig.Dispose();
--Daniel
http://staff.newtelligence.com/danielf/
--Original Message--
From: benoit [mailto:benoit@.discussions.microsoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: System.drawing.image
Subject: System.drawing.image
Hi,
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality =
CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is
being
used by another process."
Does anyone know what I can do about these issues?
Try getting the actual path of your posted file from System.IO.Path
namespace. You can use it like this:
string FileName =
System.IO.Path.GetFileName(fileUpload.PostedFile.FileName); // fileUpload is
the id of fileupload html control
Zeeshan
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.
graphicOrig.Dispose();
rectOrig.Dispose();
Zeeshan.
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
thanks
it worked !
"Zeeshan Muhammad" wrote:

> Sorry forgot to mention. You cannot manipulate an image at client side,
> therefore you need to save the image at server in order to resize it. And
> for the delete problem, dispose the Graphics and Rectange object that you
> have created before deleting the image.
> graphicOrig.Dispose();
> rectOrig.Dispose();
> Zeeshan.
> http://zishu.blogspot.com
> "benoit" <benoit@.discussions.microsoft.com> wrote in message
> news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
>
>
thanks
it worked !
"Daniel Fisher(lennybacon)" wrote:

> Try also
> graphicOrig.Dispose();
>
> --Daniel
> http://staff.newtelligence.com/danielf/
>
>
> --Original Message--
> From: benoit [mailto:benoit@.discussions.microsoft.com]
> Posted At: Monday, January 23, 2006 12:21 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: System.drawing.image
> Subject: System.drawing.image
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile)
> that I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
> getting a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to
> do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>

System.Drawing.Image.FromFile from URL?

can i create a system.drawing.Image from a url. using
http://www.domain.com/image.jpg instead of c:\image.jpg. ?
thanks!No, but you can use the WebClient or WebRequest classes to bring the
bytes to the local computer and then create the Image obect.
HTH,
Scott
http://www.OdeToCode.com
On 18 Sep 2004 09:23:29 -0700, jcharth@.hotmail.com (Joseph) wrote:

>can i create a system.drawing.Image from a url. using
>http://www.domain.com/image.jpg instead of c:\image.jpg. ?
>thanks!
As scott mentioned, you do not have any method that can directly read the
image from URL.
Use webclient and read it into a byte[] using DownloadData
then you Image class to load it
Regards,
Hermit Dave
(http://hdave.blogspot.com)
"Joseph" <jcharth@.hotmail.com> wrote in message
news:2f2b8b0b.0409180823.2a6f2f18@.posting.google.com...
> can i create a system.drawing.Image from a url. using
> http://www.domain.com/image.jpg instead of c:\image.jpg. ?
> thanks!

System.Drawing.Image.FromFile from URL?

can i create a system.drawing.Image from a url. using
http://www.domain.com/image.jpg instead of c:\image.jpg. ?
thanks!No, but you can use the WebClient or WebRequest classes to bring the
bytes to the local computer and then create the Image obect.

HTH,

--
Scott
http://www.OdeToCode.com

On 18 Sep 2004 09:23:29 -0700, jcharth@.hotmail.com (Joseph) wrote:

>can i create a system.drawing.Image from a url. using
>http://www.domain.com/image.jpg instead of c:\image.jpg. ?
>thanks!
As scott mentioned, you do not have any method that can directly read the
image from URL.
Use webclient and read it into a byte[] using DownloadData
then you Image class to load it

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Joseph" <jcharth@.hotmail.com> wrote in message
news:2f2b8b0b.0409180823.2a6f2f18@.posting.google.c om...
> can i create a system.drawing.Image from a url. using
> http://www.domain.com/image.jpg instead of c:\image.jpg. ?
> thanks!

System.Drawing.Image.Save() on Transparent GIF

I am creating GIF images with transparent backgrounds on-the-fly for a web
app and rendering them by using
System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF).

I am confident that the transparency is working properly because if I save
the created image to the local hard disk and then view it in a web page or an
image editor, the transparency is correct. I can also view the transparency
on-the-fly in a Windows.Forms application.

Yet, when I render the image on-the-fly to the Response.OutputStream, I lose
the transparency and the background color is displayed in the page.

Has anyone got any ideas or experience in rendering transparent GIFs this way?

Thanks,
--
Dale Preston
MCAD C#
MCSE, MCDBAHello Dale,

From your description, you've programmatically create an transparent gif
image and flush it into ASP.NET page's response stream. However, you found
the output image lose the transparency, correct?

Based on my understanding, it is likely that the bits save into the
response stream is different from the expected transparent gif's binary
bits. I suggest you test through the following means:

1. first use your code to generate the gif and save it into a disk file(gif
file), make sure that the gif file is working as transparent one.

2. use ASP.NET code to write the gif file into response stream as below:

===============
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "image/gif"

Response.WriteFile("D:\temp\web_temp\images\duglogobigtextcolor.gif")

Response.End()

End Sub
===============

based on my test, the above code can correctly flush a correct transparent
gif out to client-side. If the above test also return a non-transparent
one, it seems the generated gif has some bits get corrupted.

Please feel free to let me know if you have any other finding or anything I
missed.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
Thanks, Steven. I was afraid you were going to say that. Our web
infrastructure policies don't generally allow web apps to write to the local
disk so that's going to be a problem. I may have to look for another
alternative.

The goal was to present an error message in a text bubble with the bubble
hook pointing to the form field with the improper value. The transparent GIF
seemed like just the ticket.

Do you have any other suggestions or know of articles or examples of
alternative methods for displaying text in a bubble like that on-the-fly?

I built my code following the examples in KB #319061 and
http://www.bobpowell.net/giftransparency.htm. Do you know if I would have
the same problem with a transparent PNG? If a PNG is a possibility, do you
know of any documentation on how to set the transparency in a PNG using .Net?
--
Dale Preston
MCAD C#
MCSE, MCDBA

"Steven Cheng[MSFT]" wrote:

Quote:

Originally Posted by

Hello Dale,
>
From your description, you've programmatically create an transparent gif
image and flush it into ASP.NET page's response stream. However, you found
the output image lose the transparency, correct?
>
Based on my understanding, it is likely that the bits save into the
response stream is different from the expected transparent gif's binary
bits. I suggest you test through the following means:
>
1. first use your code to generate the gif and save it into a disk file(gif
file), make sure that the gif file is working as transparent one.
>
2. use ASP.NET code to write the gif file into response stream as below:
>
===============
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "image/gif"
>
>
Response.WriteFile("D:\temp\web_temp\images\duglogobigtextcolor.gif")
>
Response.End()
>
>
>
End Sub
===============
>
based on my test, the above code can correctly flush a correct transparent
gif out to client-side. If the above test also return a non-transparent
one, it seems the generated gif has some bits get corrupted.
>
Please feel free to let me know if you have any other finding or anything I
missed.
>
Sincerely,
>
Steven Cheng
>
Microsoft MSDN Online Support Lead
>
>
This posting is provided "AS IS" with no warranties, and confers no rights.
>
>


Just FYI, Steven.

I was able to resolve my problem and, hopefully make my solution more robust
than it may have otherwise been.

The problem was that the Bitmap object I was drawing on using the Graphics
class seems to corrupt the palette by duplicating a single palette entry
which was, coincidentally, the transparent color.

While I was aware of the duplication, I was skipping the first occurrence
because no pixels pointed to it. The second occurrence was where all the
transparent pixels pointed and that is the entry I set the alpha to 0 on.
This issue did not cause any problems in Windows.Forms, in Paint Shop Pro, in
Microsoft Image Composer, or if I saved to disk and then opened the saved
file in a web page.

For some reason, though, it did create a problem when saving to the
Response.OutputStream because the method requires re-assigning the ImageType.
There should be an overload of the Save method that writes to a Stream
without having to pass the ImageType just as there is an overload that saves
to a file.

The bottom line is, I re-wrote my code to detect duplicate entries in the
palette, then modify all pixels that pointed to any of the duplicates so that
they point to the first occurrence of the color, and then modify all of the
remaining duplicate palette entries so that they are unique. With this done,
I was able to save my image to the Response.OutputStream with the
transparency working as expected.

Thanks again for your help.

Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA

"Dale" wrote:

Quote:

Originally Posted by

Thanks, Steven. I was afraid you were going to say that. Our web
infrastructure policies don't generally allow web apps to write to the local
disk so that's going to be a problem. I may have to look for another
alternative.
>
The goal was to present an error message in a text bubble with the bubble
hook pointing to the form field with the improper value. The transparent GIF
seemed like just the ticket.
>
Do you have any other suggestions or know of articles or examples of
alternative methods for displaying text in a bubble like that on-the-fly?
>
I built my code following the examples in KB #319061 and
http://www.bobpowell.net/giftransparency.htm. Do you know if I would have
the same problem with a transparent PNG? If a PNG is a possibility, do you
know of any documentation on how to set the transparency in a PNG using .Net?
--
Dale Preston
MCAD C#
MCSE, MCDBA
>
>
"Steven Cheng[MSFT]" wrote:
>

Quote:

Originally Posted by

Hello Dale,

From your description, you've programmatically create an transparent gif
image and flush it into ASP.NET page's response stream. However, you found
the output image lose the transparency, correct?

Based on my understanding, it is likely that the bits save into the
response stream is different from the expected transparent gif's binary
bits. I suggest you test through the following means:

1. first use your code to generate the gif and save it into a disk file(gif
file), make sure that the gif file is working as transparent one.

2. use ASP.NET code to write the gif file into response stream as below:

===============
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "image/gif"

Response.WriteFile("D:\temp\web_temp\images\duglogobigtextcolor.gif")

Response.End()

End Sub
===============

based on my test, the above code can correctly flush a correct transparent
gif out to client-side. If the above test also return a non-transparent
one, it seems the generated gif has some bits get corrupted.

Please feel free to let me know if you have any other finding or anything I
missed.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.


Hi Dale,

Thanks for your followup.

I'm glad that you've figured out the problem and found a workable solution.

As always, welcome to post here when you need any help from us.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

System.Drawing.Image.Save() on Transparent GIF

I am creating GIF images with transparent backgrounds on-the-fly for a web
app and rendering them by using
System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF).
I am confident that the transparency is working properly because if I save
the created image to the local hard disk and then view it in a web page or a
n
image editor, the transparency is correct. I can also view the transparency
on-the-fly in a Windows.Forms application.
Yet, when I render the image on-the-fly to the Response.OutputStream, I lose
the transparency and the background color is displayed in the page.
Has anyone got any ideas or experience in rendering transparent GIFs this wa
y?
Thanks,
--
Dale Preston
MCAD C#
MCSE, MCDBAHello Dale,
From your description, you've programmatically create an transparent gif
image and flush it into ASP.NET page's response stream. However, you found
the output image lose the transparency, correct?
Based on my understanding, it is likely that the bits save into the
response stream is different from the expected transparent gif's binary
bits. I suggest you test through the following means:
1. first use your code to generate the gif and save it into a disk file(gif
file), make sure that the gif file is working as transparent one.
2. use ASP.NET code to write the gif file into response stream as below:
===============
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "image/gif"
Response.WriteFile(" D:\temp\web_temp\images\duglogobigtextco
lor.gif")
Response.End()
End Sub
===============
based on my test, the above code can correctly flush a correct transparent
gif out to client-side. If the above test also return a non-transparent
one, it seems the generated gif has some bits get corrupted.
Please feel free to let me know if you have any other finding or anything I
missed.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Thanks, Steven. I was afraid you were going to say that. Our web
infrastructure policies don't generally allow web apps to write to the local
disk so that's going to be a problem. I may have to look for another
alternative.
The goal was to present an error message in a text bubble with the bubble
hook pointing to the form field with the improper value. The transparent GI
F
seemed like just the ticket.
Do you have any other suggestions or know of articles or examples of
alternative methods for displaying text in a bubble like that on-the-fly?
I built my code following the examples in KB #319061 and
http://www.bobpowell.net/giftransparency.htm. Do you know if I would have
the same problem with a transparent PNG? If a PNG is a possibility, do you
know of any documentation on how to set the transparency in a PNG using .Net
?
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Steven Cheng[MSFT]" wrote:

> Hello Dale,
> From your description, you've programmatically create an transparent gif
> image and flush it into ASP.NET page's response stream. However, you found
> the output image lose the transparency, correct?
> Based on my understanding, it is likely that the bits save into the
> response stream is different from the expected transparent gif's binary
> bits. I suggest you test through the following means:
> 1. first use your code to generate the gif and save it into a disk file(gi
f
> file), make sure that the gif file is working as transparent one.
> 2. use ASP.NET code to write the gif file into response stream as below:
> ===============
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
> Response.ClearHeaders()
> Response.ClearContent()
> Response.ContentType = "image/gif"
>
> Response.WriteFile(" D:\temp\web_temp\images\duglogobigtextco
lor.gif")
> Response.End()
>
> End Sub
> ===============
> based on my test, the above code can correctly flush a correct transparent
> gif out to client-side. If the above test also return a non-transparent
> one, it seems the generated gif has some bits get corrupted.
> Please feel free to let me know if you have any other finding or anything
I
> missed.
> Sincerely,
> Steven Cheng
> Microsoft MSDN Online Support Lead
>
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>
Just FYI, Steven.
I was able to resolve my problem and, hopefully make my solution more robust
than it may have otherwise been.
The problem was that the Bitmap object I was drawing on using the Graphics
class seems to corrupt the palette by duplicating a single palette entry
which was, coincidentally, the transparent color.
While I was aware of the duplication, I was skipping the first occurrence
because no pixels pointed to it. The second occurrence was where all the
transparent pixels pointed and that is the entry I set the alpha to 0 on.
This issue did not cause any problems in Windows.Forms, in Paint Shop Pro, i
n
Microsoft Image Composer, or if I saved to disk and then opened the saved
file in a web page.
For some reason, though, it did create a problem when saving to the
Response.OutputStream because the method requires re-assigning the ImageType
.
There should be an overload of the Save method that writes to a Stream
without having to pass the ImageType just as there is an overload that saves
to a file.
The bottom line is, I re-wrote my code to detect duplicate entries in the
palette, then modify all pixels that pointed to any of the duplicates so tha
t
they point to the first occurrence of the color, and then modify all of the
remaining duplicate palette entries so that they are unique. With this done
,
I was able to save my image to the Response.OutputStream with the
transparency working as expected.
Thanks again for your help.
Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Dale" wrote:
> Thanks, Steven. I was afraid you were going to say that. Our web
> infrastructure policies don't generally allow web apps to write to the loc
al
> disk so that's going to be a problem. I may have to look for another
> alternative.
> The goal was to present an error message in a text bubble with the bubble
> hook pointing to the form field with the improper value. The transparent
GIF
> seemed like just the ticket.
> Do you have any other suggestions or know of articles or examples of
> alternative methods for displaying text in a bubble like that on-the-fly?
> I built my code following the examples in KB #319061 and
> http://www.bobpowell.net/giftransparency.htm. Do you know if I would have
> the same problem with a transparent PNG? If a PNG is a possibility, do yo
u
> know of any documentation on how to set the transparency in a PNG using .N
et?
> --
> Dale Preston
> MCAD C#
> MCSE, MCDBA
>
> "Steven Cheng[MSFT]" wrote:
>
Hi Dale,
Thanks for your followup.
I'm glad that you've figured out the problem and found a workable solution.
As always, welcome to post here when you need any help from us.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

System.Drawing.Printing

Can the System.Drawing.Print namespace (and it's print methods) be used in
ASP.NET ? Can we direct an output to a printer using these classes ? If not,
what is the alternative ?You can use any namespace with ASP.Net, and you can do anything.

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

"moko" <nospam-r_chakravarthy@.hotmail.com> wrote in message
news:unQO5kB$DHA.620@.TK2MSFTNGP11.phx.gbl...
> Can the System.Drawing.Print namespace (and it's print methods) be used in
> ASP.NET ? Can we direct an output to a printer using these classes ? If
not,
> what is the alternative ?
I thought "System.Drawing" used GDI+, which in turn is in the context of
Windows, not a web-browser ? Is that not so ?

"Kevin Spencer" <kevin@.takempis.com> wrote in message
news:etWYM3G$DHA.2432@.TK2MSFTNGP11.phx.gbl...
> You can use any namespace with ASP.Net, and you can do anything.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
> "moko" <nospam-r_chakravarthy@.hotmail.com> wrote in message
> news:unQO5kB$DHA.620@.TK2MSFTNGP11.phx.gbl...
> > Can the System.Drawing.Print namespace (and it's print methods) be used
in
> > ASP.NET ? Can we direct an output to a printer using these classes ? If
> not,
> > what is the alternative ?
No, It is not so. An ASP.Net application is the same as any other
application. For example, you can use GDI+ to create images which you stream
out to a browser on the fly. In any case, the question was about printing,
which uses drawing. Now, I am nt sure that the person who asked understand
that the printing classes will only work on the server side (unless they use
a client-side .Net Windows Form), but there may be a reason why the person
wants their app to do some printing on the server.

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

"moko" <nospam-r_chakravarthy@.hotmail.com> wrote in message
news:esfXfBH$DHA.2412@.TK2MSFTNGP12.phx.gbl...
> I thought "System.Drawing" used GDI+, which in turn is in the context of
> Windows, not a web-browser ? Is that not so ?
>
> "Kevin Spencer" <kevin@.takempis.com> wrote in message
> news:etWYM3G$DHA.2432@.TK2MSFTNGP11.phx.gbl...
> > You can use any namespace with ASP.Net, and you can do anything.
> > --
> > HTH,
> > Kevin Spencer
> > .Net Developer
> > Microsoft MVP
> > Big things are made up
> > of lots of little things.
> > "moko" <nospam-r_chakravarthy@.hotmail.com> wrote in message
> > news:unQO5kB$DHA.620@.TK2MSFTNGP11.phx.gbl...
> > > Can the System.Drawing.Print namespace (and it's print methods) be
used
> in
> > > ASP.NET ? Can we direct an output to a printer using these classes ?
If
> > not,
> > > what is the alternative ?
> > >

System.Drawing.Printing for web form?

Dear All,
I knew that if i want to make some printout in window form, i can use
"System.Drawing.Printing" namespace.
Is it possible to use this namespace in web form in asp.net?
Thank you
Regards,
Angushi
you print form in the server or in the client?
daniel #
"angus" <angus@.angus.com> wrote in message
news:ukXOkZQTEHA.3512@.TK2MSFTNGP12.phx.gbl...
> Dear All,
> I knew that if i want to make some printout in window form, i can use
> "System.Drawing.Printing" namespace.
> Is it possible to use this namespace in web form in asp.net?
> Thank you
> Regards,
> Angus
>

System.Drawing.Printing for web form?

Dear All,

I knew that if i want to make some printout in window form, i can use
"System.Drawing.Printing" namespace.
Is it possible to use this namespace in web form in asp.net?

Thank you

Regards,
Angushi

you print form in the server or in the client?

daniel #
"angus" <angus@.angus.com> wrote in message
news:ukXOkZQTEHA.3512@.TK2MSFTNGP12.phx.gbl...
> Dear All,
> I knew that if i want to make some printout in window form, i can use
> "System.Drawing.Printing" namespace.
> Is it possible to use this namespace in web form in asp.net?
> Thank you
> Regards,
> Angus

System.Drawing: Error when using a .bmp or .gif file but not when .jpg

I each time get errors when I use an .bmp or ,.gif file as source but
whenever I use a .jpg file it works perfect.
Why is that? and how to fix it?
I almost have no knowledge about the system.drawing and so I am in the dark
about this.
This is my code
--
<%@dotnet.itags.org. Page Language="vb" %>
<%@dotnet.itags.org. import namespace="system.drawing" %>
<%@dotnet.itags.org. import namespace="system.drawing.imaging" %>
<%@dotnet.itags.org. import namespace="system.drawing.drawing2d" %>
<%
' initialise objects
dim strFilename as string
dim b as New System.Drawing.Bitmap(server.mappath("test.jpg"))
dim g as graphics = graphics.fromimage(b)
g.smoothingMode = smoothingMode.antiAlias
dim stringFormat As New StringFormat()
g.drawString("The Magic Word", New font("arial",3),systembrushes.windowtext,
New pointF(2,2), stringFormat)
' Set the content type
response.contenttype="image/jpeg"
' send the image to the viewer
b.save(response.outputstream, b.rawformat)
' tidy up
b.dispose()
%>Hi Richard,
As for the "A Graphics object cannot be created from an image that has an
indexed pixel format" error, it is caused by the Graphic object can't been
created from some certain image format which contains indexed pixel. I've
done some tests and one means is load the image and convert it into jpeg
format first and then create Graphich object to manipulate it. For example,
here is my test code:
========================================
==========
Private Sub Output_Image(ByVal path As String)
Try
Dim img As Image = Image.FromFile(path)
Dim stream As New System.IO.MemoryStream
img.Save(stream, ImageFormat.Jpeg)
Dim imgNew As Image = Image.FromStream(stream)
Dim g As Graphics = Graphics.FromImage(imgNew)
g.DrawString("MS Test", New Font("Verdana", 20,
FontStyle.Bold), _
New SolidBrush(Color.Beige), 0, 0)
Response.Clear()
Response.ContentType = "Image/jpeg"
imgNew.Save(Response.OutputStream, ImageFormat.Jpeg)
Response.End()
img.Dispose()
stream.Close()
imgNew.Dispose()
Catch ex As Exception
Response.Write("<br>" + ex.Message)
End Try
End Sub
========================================
=========
Please have a try to see whether it works for you. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
thx a lot, this really helped me out.
I got no errors and with some thinking I made sure ppl can't link to my
files. (put a http://www. infront of url to view)
digifan.nl/ShowGalleryImage.aspx? img=Jlz1wB3JMO636rzX3rGMrpOK7mbHBTzFQQ1O
Q%2
fJ5V3Y%3d
and looking at the properties of the image it shows:
digifan.nl/ShowFullImage.aspx? img=Jlz1wB3JMO636rzX3rGMrpOK7mbHBTzFQQ1O
Q%2fJ5
V3Y%3d
which is only the image.
Again thx, i am going to read a bit some more about the system.drawing and
what it al can do but now i have an understanding of
the general thing.
Richard
"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> schreef in bericht
news:VQpV0n2UEHA.3204@.cpmsftngxa10.phx.gbl...
> Hi Richard,
> As for the "A Graphics object cannot be created from an image that has an
> indexed pixel format" error, it is caused by the Graphic object can't been
> created from some certain image format which contains indexed pixel. I've
> done some tests and one means is load the image and convert it into jpeg
> format first and then create Graphich object to manipulate it. For
example,
> here is my test code:
> ========================================
==========
> Private Sub Output_Image(ByVal path As String)
> Try
> Dim img As Image = Image.FromFile(path)
> Dim stream As New System.IO.MemoryStream
> img.Save(stream, ImageFormat.Jpeg)
> Dim imgNew As Image = Image.FromStream(stream)
> Dim g As Graphics = Graphics.FromImage(imgNew)
> g.DrawString("MS Test", New Font("Verdana", 20,
> FontStyle.Bold), _
> New SolidBrush(Color.Beige), 0, 0)
> Response.Clear()
> Response.ContentType = "Image/jpeg"
> imgNew.Save(Response.OutputStream, ImageFormat.Jpeg)
> Response.End()
>
> img.Dispose()
> stream.Close()
> imgNew.Dispose()
> Catch ex As Exception
> Response.Write("<br>" + ex.Message)
> End Try
> End Sub
> ========================================
=========
> Please have a try to see whether it works for you. Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
>

System.Drawing: Error when using a .bmp or .gif file but not when .jpg

I each time get errors when I use an .bmp or ,.gif file as source but
whenever I use a .jpg file it works perfect.
Why is that? and how to fix it?

I almost have no knowledge about the system.drawing and so I am in the dark
about this.

This is my code
-----------

<%@dotnet.itags.org. Page Language="vb" %>
<%@dotnet.itags.org. import namespace="system.drawing" %>
<%@dotnet.itags.org. import namespace="system.drawing.imaging" %>
<%@dotnet.itags.org. import namespace="system.drawing.drawing2d" %>
<%

' initialise objects
dim strFilename as string
dim b as New System.Drawing.Bitmap(server.mappath("test.jpg"))
dim g as graphics = graphics.fromimage(b)
g.smoothingMode = smoothingMode.antiAlias
dim stringFormat As New StringFormat()
g.drawString("The Magic Word", New font("arial",3),systembrushes.windowtext,
New pointF(2,2), stringFormat)

' Set the content type
response.contenttype="image/jpeg"

' send the image to the viewer
b.save(response.outputstream, b.rawformat)

' tidy up
b.dispose()

%thx a lot, this really helped me out.

I got no errors and with some thinking I made sure ppl can't link to my
files. (put a http://www. infront of url to view)

digifan.nl/ShowGalleryImage.aspx?img=Jlz1wB3JMO636rzX3rGMrpOK 7mbHBTzFQQ1OQ%2
fJ5V3Y%3d

and looking at the properties of the image it shows:

digifan.nl/ShowFullImage.aspx?img=Jlz1wB3JMO636rzX3rGMrpOK7mb HBTzFQQ1OQ%2fJ5
V3Y%3d

which is only the image.

Again thx, i am going to read a bit some more about the system.drawing and
what it al can do but now i have an understanding of
the general thing.

Richard

"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> schreef in bericht
news:VQpV0n2UEHA.3204@.cpmsftngxa10.phx.gbl...
> Hi Richard,
> As for the "A Graphics object cannot be created from an image that has an
> indexed pixel format" error, it is caused by the Graphic object can't been
> created from some certain image format which contains indexed pixel. I've
> done some tests and one means is load the image and convert it into jpeg
> format first and then create Graphich object to manipulate it. For
example,
> here is my test code:
> ==================================================
> Private Sub Output_Image(ByVal path As String)
> Try
> Dim img As Image = Image.FromFile(path)
> Dim stream As New System.IO.MemoryStream
> img.Save(stream, ImageFormat.Jpeg)
> Dim imgNew As Image = Image.FromStream(stream)
> Dim g As Graphics = Graphics.FromImage(imgNew)
> g.DrawString("MS Test", New Font("Verdana", 20,
> FontStyle.Bold), _
> New SolidBrush(Color.Beige), 0, 0)
> Response.Clear()
> Response.ContentType = "Image/jpeg"
> imgNew.Save(Response.OutputStream, ImageFormat.Jpeg)
> Response.End()
>
> img.Dispose()
> stream.Close()
> imgNew.Dispose()
> Catch ex As Exception
> Response.Write("<br>" + ex.Message)
> End Try
> End Sub
> =================================================
> Please have a try to see whether it works for you. Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Richard,

As for the "A Graphics object cannot be created from an image that has an
indexed pixel format" error, it is caused by the Graphic object can't been
created from some certain image format which contains indexed pixel. I've
done some tests and one means is load the image and convert it into jpeg
format first and then create Graphich object to manipulate it. For example,
here is my test code:
==================================================
Private Sub Output_Image(ByVal path As String)
Try

Dim img As Image = Image.FromFile(path)
Dim stream As New System.IO.MemoryStream
img.Save(stream, ImageFormat.Jpeg)
Dim imgNew As Image = Image.FromStream(stream)

Dim g As Graphics = Graphics.FromImage(imgNew)

g.DrawString("MS Test", New Font("Verdana", 20,
FontStyle.Bold), _
New SolidBrush(Color.Beige), 0, 0)

Response.Clear()
Response.ContentType = "Image/jpeg"

imgNew.Save(Response.OutputStream, ImageFormat.Jpeg)
Response.End()

img.Dispose()
stream.Close()
imgNew.Dispose()

Catch ex As Exception
Response.Write("<br>" + ex.Message)
End Try

End Sub
=================================================

Please have a try to see whether it works for you. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

System.Drawing.Text font question

Hello,

I've looked for answer to this everywhere but with no luck..

I need to dynamically create graphic text from database values. I've got this working fine if I use arial as the font but I want to use another font.

Now - presumably I can use any font installed on the server? But it doesn't seem to work. I want to use a font called blurLight but it just outputs in arial (I think - it's a standard font anyway)

Is there anything else I need to do to make other fonts available to asp.net other than just installing them on the server???

Thank you.Post some code so we can have a looksie
Alright - I will

<%@. Page Language="VB" Debug="True" %>
<%@. Import Namespace="System.Drawing" %>
<%@. Import Namespace="System.Drawing.Imaging" %>
<%@. Import Namespace="System.Drawing.Text" %>
<%
' Declare Vars
Dim objBMP As System.Drawing.Bitmap
Dim objGraphics As System.Drawing.Graphics
Dim objFont As System.Drawing.Font

objBMP = New Bitmap(100, 30)

objGraphics = System.Drawing.Graphics.FromImage(objBMP)

objGraphics.Clear(Color.Green)

objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias

objFont = New Font("Arial", 16, FontStyle.Bold)

objGraphics.DrawString("Hello World", objFont, Brushes.White, 3, 3)

Response.ContentType = "image/GIF"
objBMP.Save(Response.OutputStream, ImageFormat.Gif)

objFont.Dispose()
objGraphics.Dispose()
objBMP.Dispose()
%

That code works fine but when I replace Arial with the font I want to use - it doesn't work..

Any ideas??

system.enterpriseservices.dll error

I am running a web app on w2k3/IIS 6.0/ASP.net 2.0. This app runs fine on a different server. The error message I get is

Compiler Error Message:CS0006: Metadata file 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll' could not be found

I have seen solutions to remove the "<identity impersonate="true" />" setting from the web.config file. That has not been helpful. Another solution was to delete the system.enterpriseservices.dll from C:\Windows\assembly. I have deleted the file, copied a new .dll, and that did not work. I have reinstalled IIS and ASP.Net 2.0 as well. So far, no dice. Any other ideas are greatly welcomed!


AJ

Hello AJ,

This may be a dumb question, but is the assembly in the GAC on the deployment server? If it isn't, you should be able to add it by running "gacutil /if System.EnterpriseServices.dll" using the 2.0 version of gacutil.exe.

HTH,
Clay


Clay,

Thanks for the response. I just got the problem figured out today.

The file permissions were screwed up. Users did not have read and execute permissions to this folder:
C:\WINDOWS\WinSxS\x86_System.EnterpriseServices_b03f5f7f11d50a3a_2.0.0.0_x-ww_7d5f3790

After I fixed that I got a similar error message as before but it mentioned a system.enterpriseServices.Wrapper.dll and found out that this file was missing
C:\WINDOWS\WinSxS\x86_System.EnterpriseServices_b03f5f7f11d50a3a_2.0.0.0_x-ww_7d5f3790\System.EnterpriseServices.Wrapper.dll

Now it is running like a champ!

AJ

System.EventHandler created but event not fired

I'm having this exact same problem:

http://groups.google.com/group/micr...d072e420a5a96ea
I'm having problems with dropdownlists in a random fashion, some of
them work, and some dont, and the code for eventhandler binding is
there.

for example:

private void InitializeComponent()
{
this.cbBranches.SelectedIndexChanged += new
System.EventHandler(this.cbBranches_SelectedIndexC hanged_1);
..
..
..
}

SelectedIndexChanged_1 never gets called
anyone ever solved this?Make sure InitializeComponent is being called. (breakpoint)

Are you setting the AutoPostBack property to True?

If you set it to false, then the code will only run when you do a postback
(which could be several different things triggering a postback)

<lauralucas@.gmail.comwrote in message
news:1154448495.232168.8670@.s13g2000cwa.googlegrou ps.com...

Quote:

Originally Posted by

I'm having this exact same problem:
>
>


http://groups.google.com/group/micr...d072e420a5a96ea

Quote:

Originally Posted by

>
I'm having problems with dropdownlists in a random fashion, some of
them work, and some dont, and the code for eventhandler binding is
there.
>
for example:
>
private void InitializeComponent()
{
this.cbBranches.SelectedIndexChanged += new
System.EventHandler(this.cbBranches_SelectedIndexC hanged_1);
.
.
.
}
>
SelectedIndexChanged_1 never gets called
anyone ever solved this?
>


AutoPostBack property!!! that was it!! thanks a lot!! =D
sloan wrote:

Quote:

Originally Posted by

Make sure InitializeComponent is being called. (breakpoint)
>
Are you setting the AutoPostBack property to True?
>
If you set it to false, then the code will only run when you do a postback
(which could be several different things triggering a postback)
>
>
>
>
<lauralucas@.gmail.comwrote in message
news:1154448495.232168.8670@.s13g2000cwa.googlegrou ps.com...

Quote:

Originally Posted by

I'm having this exact same problem:


http://groups.google.com/group/micr...d072e420a5a96ea

Quote:

Originally Posted by


I'm having problems with dropdownlists in a random fashion, some of
them work, and some dont, and the code for eventhandler binding is
there.

for example:

private void InitializeComponent()
{
this.cbBranches.SelectedIndexChanged += new
System.EventHandler(this.cbBranches_SelectedIndexC hanged_1);
.
.
.
}

SelectedIndexChanged_1 never gets called
anyone ever solved this?


You should go post your new found knowledge at that other post.

To keep making the world a better place.

<lauralucas@.gmail.comwrote in message
news:1154453257.813172.113540@.b28g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

AutoPostBack property!!! that was it!! thanks a lot!! =D
sloan wrote:

Quote:

Originally Posted by

Make sure InitializeComponent is being called. (breakpoint)

Are you setting the AutoPostBack property to True?

If you set it to false, then the code will only run when you do a


postback

Quote:

Originally Posted by

Quote:

Originally Posted by

(which could be several different things triggering a postback)

<lauralucas@.gmail.comwrote in message
news:1154448495.232168.8670@.s13g2000cwa.googlegrou ps.com...

Quote:

Originally Posted by

I'm having this exact same problem:
>
>



http://groups.google.com/group/micr...d072e420a5a96ea

Quote:

Originally Posted by

Quote:

Originally Posted by

Quote:

Originally Posted by

>
I'm having problems with dropdownlists in a random fashion, some of
them work, and some dont, and the code for eventhandler binding is
there.
>
for example:
>
private void InitializeComponent()
{
this.cbBranches.SelectedIndexChanged += new
System.EventHandler(this.cbBranches_SelectedIndexC hanged_1);
.
.
.
}
>
SelectedIndexChanged_1 never gets called
anyone ever solved this?
>


>

system.exception.handles : Object Must Inconvertible

i would like to execute an stored procedure command from asp.net.
i think all of my syntax is generaly true. but when i test it in ie browser. an error occured and
show the messages :
system.exception.handles : Object Must Inconvertible
anyone help me....
thank u very much.Crying [:'(]

Can you post the code that is causing the error?

Note: Please post the appropriate section(s), not the whole page.

System.ExecutionEngineException problem

I have a stable app developed on ASP.NET 1.1 that I'm porting to 2.0.
However, I've noticed that on one page, if I click a button to perform some
business logic (which runs fine), then click on a hyperlink to move to a
different page, I get a 'System.ExecutionEngineException' exception. There
is no line highlighted in the debugger.
I'm not using interop or other threads.
Event viewer shows:
.NET Runtime version 2.0.50727.42 - Fatal Execution Engine Error (7A05E2B3)
(80131506)
I also sometimes see:
aspnet_wp.exe (PID: 2324) stopped unexpectedly.
It fails predictably on the dev web server in VS2005, less regularly on IIS
(although it does still fail).
I've tried to create a simplified program to reproduce the problem - so far
without success. However I did notice that the problem was worsened by some
code returning an array (15-20) of small Dictionary<> objects. I added a
conversion routine to turn them into arrays of structs, and some of the
problems went away. Is this something to do with memory-shortage' My PC has
800mb, with around 80mb free when running the code.
Whats going on? Is this a bug in .NET2, or is there something stupid in my
code? Advice would be welcome!!
XP Pro sp2, .NET 2.0.50727.42, VS2005, SQL2005
Thanks,
JohnI've reported this to Microsoft, and they can reproduce the problem. I'll
post an update when I know more.
John
"John" <jsparrowNOSPAM@.ecclesdeletethiscollege.ac.uk> wrote in message
news:OAQ9HMLPGHA.812@.TK2MSFTNGP10.phx.gbl...
>I have a stable app developed on ASP.NET 1.1 that I'm porting to 2.0.
> However, I've noticed that on one page, if I click a button to perform
> some business logic (which runs fine), then click on a hyperlink to move
> to a different page, I get a 'System.ExecutionEngineException' exception.
> There is no line highlighted in the debugger.
Microsoft report the problems stems back to a Dictionary<decimal,double>
instance.
Looks like the CLR can't cope with this for some reason. Be afraid....
John
"John" <jsparrowNOSPAM@.ecclesdeletethiscollege.ac.uk> wrote in message
news:e2h74swPGHA.5296@.TK2MSFTNGP09.phx.gbl...

System.ExecutionEngineException problem

I have a stable app developed on ASP.NET 1.1 that I'm porting to 2.0.

However, I've noticed that on one page, if I click a button to perform some
business logic (which runs fine), then click on a hyperlink to move to a
different page, I get a 'System.ExecutionEngineException' exception. There
is no line highlighted in the debugger.

I'm not using interop or other threads.

Event viewer shows:

..NET Runtime version 2.0.50727.42 - Fatal Execution Engine Error (7A05E2B3)
(80131506)

I also sometimes see:

aspnet_wp.exe (PID: 2324) stopped unexpectedly.

It fails predictably on the dev web server in VS2005, less regularly on IIS
(although it does still fail).

I've tried to create a simplified program to reproduce the problem - so far
without success. However I did notice that the problem was worsened by some
code returning an array (15-20) of small Dictionary<> objects. I added a
conversion routine to turn them into arrays of structs, and some of the
problems went away. Is this something to do with memory-shortage?? My PC has
800mb, with around 80mb free when running the code.

Whats going on? Is this a bug in .NET2, or is there something stupid in my
code? Advice would be welcome!!

XP Pro sp2, .NET 2.0.50727.42, VS2005, SQL2005

Thanks,

JohnI've reported this to Microsoft, and they can reproduce the problem. I'll
post an update when I know more.

John

"John" <jsparrowNOSPAM@.ecclesdeletethiscollege.ac.uk> wrote in message
news:OAQ9HMLPGHA.812@.TK2MSFTNGP10.phx.gbl...
>I have a stable app developed on ASP.NET 1.1 that I'm porting to 2.0.
> However, I've noticed that on one page, if I click a button to perform
> some business logic (which runs fine), then click on a hyperlink to move
> to a different page, I get a 'System.ExecutionEngineException' exception.
> There is no line highlighted in the debugger.
Microsoft report the problems stems back to a Dictionary<decimal,double>
instance.

Looks like the CLR can't cope with this for some reason. Be afraid....

John

"John" <jsparrowNOSPAM@.ecclesdeletethiscollege.ac.uk> wrote in message
news:e2h74swPGHA.5296@.TK2MSFTNGP09.phx.gbl...

>> However, I've noticed that on one page, if I click a button to perform
>> some business logic (which runs fine), then click on a hyperlink to move
>> to a different page, I get a 'System.ExecutionEngineException' exception.
>> There is no line highlighted in the debugger.

System.FormatException: Index (zero based) must be greater than or equal to zero

Hi

I am absolutely out of my wits on how to handle this problem. I'm just beginning to learn ASP.NEt.

I get this error while trying to insert new registration info on an access table:

System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

Here's my code:

Dim cmdInsert as OleDbCommand
Dim strInsert as String
strInsert="Insert into Userdetail (login_id,password, Name, Designation, Company, " _
& "Address, Zip, City, Country, Fax, email, phone, employee_size, sales)" _
& " VALUES (@dotnet.itags.org.loginid, @dotnet.itags.org.password, @dotnet.itags.org.Name, @dotnet.itags.org.Designation,@dotnet.itags.org.Company," _
& " @dotnet.itags.org.Address, @dotnet.itags.org.Zip, @dotnet.itags.org.City, @dotnet.itags.org.Country,@dotnet.itags.org.Fax,@dotnet.itags.org.Email,@dotnet.itags.org.Phone,@dotnet.itags.org.EmployeeSize,@dotnet.itags.org.Sales)"
cmdInsert= New OleDbCommand(strInsert,conUser)
cmdInsert.Parameters.Add("@dotnet.itags.org.loginid", txtLoginID.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Password", txtPassword.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Name", txtName.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Designation", txtDesignation.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Company", txtCompany.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Address", txtAddress.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Zip", txtZip.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.City", txtCity)
cmdInsert.Parameters.Add("@dotnet.itags.org.Country", txtCountry.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Fax", txtFax.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Email", txtEmail.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Phone", txtPhone.text)
cmdInsert.Parameters.Add("@dotnet.itags.org.EmployeeSize", rbEmployeeSize.SelectedItem.Text)
cmdInsert.Parameters.Add("@dotnet.itags.org.Sales", rbSalesSize.SelectedItem.Text)
conUser.Open()
cmdInsert.ExecuteNonQuery()
conUser.Close()

Help! Please... :(I think it is something to do with rbEmployeeSize.SelectedItem.Text or/and rbSalesSize.SelectedItem.Text - what are the controls that relate to these?

DJ
I think it is something to do with rbEmployeeSize.SelectedItem.Text or/and rbSalesSize.SelectedItem.Text - what are the controls that relate to these?
These are RadioButtonLists that give out the value of the text of the Radio Button.
It may seem like a silly question but has there been an item selected in either list? - if not then the SelectedIndex property is null and therefore the Index (zero based) is not greater than or equal to zero or less than the size of the argument list.

Maybe worth adding some code to check an item was selected.

DJ
Yes, the radio buttons are being selected.

I just checked if the item was being selected and found that both of them are being selected.

Here's the html script to define asp form controls:

<form runat="server">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td colspan="2"><strong>Enter Registration Detail</strong></td>
</tr>
<tr>
<td width="18%">Login ID</td>
<td width="82%"><asp:textbox ID="txtLoginID" runat="server" />
<asp:Label ID="lblMessage" runat="server" />
<asp:requiredfieldvalidator
ControlToValidate="txtLoginID"
Text="Login ID Field Cannot be left Blank"
runat="server" />

</td>
</tr>
<tr>
<td>Password</td>
<td><asp:textbox ID="txtPassword" MaxLength="20" runat="server" TextMode="Password" />
<asp:requiredfieldvalidator
ControlToValidate="txtPassword"
Text="Password Cannot be left Blank"
runat="server" /> <asp:regularexpressionvalidator
ControlToValidate="txtPassword"
Text= "Your Password must contain between 3 and 20 characters!"
ValidationExpression="\w{3,30}"
runat="server" /> <asp:comparevalidator
ControlToValidate="txtPassWord"
ControlToCompare="txtConfirmPassword"
Text="Please Reconfirm your password"
Operator="Equal"
Type="String"
runat="server" /> </td>
</tr>
<tr>
<td>Confirm Password</td>
<td><asp:textbox ID="txtConfirmPassword" MaxLength="20" runat="server" TextMode="Password" />
<asp:requiredfieldvalidator ControlToValidate="txtConfirmPassword" Text="Please Reconfirm the password" runat="server" /> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Name</td>
<td><asp:textbox ID="txtName" runat="server" /> <asp:requiredfieldvalidator ControlToValidate="txtName" Text="Name Cannot be left Blank" runat="server" /> </td>
</tr>
<tr>
<td>Designation</td>
<td><asp:textbox ID="txtDesignation" runat="server" /> </td>
</tr>
<tr>
<td>Company</td>
<td><asp:textbox ID="txtCompany" runat="server" /> </td>
</tr>
<tr>
<td>Address</td>
<td> <asp:textbox Columns="30" ID="txtAddress" Rows="4" runat="server" TextMode="MultiLine" />
<asp:requiredfieldvalidator ControlToValidate="txtAddress" Text="Address Cannot be left Blank" runat="server" /> </td>
</tr>
<tr>
<td>City</td>
<td><asp:textbox ID="txtCity" runat="server" /> </td>
</tr>
<tr>
<td>Zip</td>
<td><asp:textbox ID="txtZip" runat="server" /> </tr>
<tr>
<td>Country</td>
<td><asp:textbox ID="txtCountry" runat="server" /> </tr>
<tr>
<td>Fax</td>
<td><asp:textbox ID="txtFax" runat="server" /> </tr>
<tr>
<td>Email</td>
<td><asp:textbox ID="txtEmail" runat="server" /> <asp:regularexpressionvalidator
ControlToValidate="txtEmail"
Text="Invalid Email Address"
Display="Dynamic"
ValidationExpression="\S+@.\S+\.\S{2,3}"
runat="server" /> </tr>
<tr>
<td>Phone</td>
<td><asp:textbox ID="txtPhone" runat="server" /> </tr>
<tr>
<td>Employee Size</td>
<td>
<asp:radiobuttonlist
ID="rbEmployeeSize"
runat="server" >
<asp:ListItem Text="Less Than 10" />
<asp:ListItem Text="10 to 49" />
<asp:listitem Text="50 to 100" />
<asp:listItem text= "Over 50" />
</asp:radiobuttonlist></td>
</tr>
<tr>
<td>Sales Size</td>
<td><asp:radiobuttonlist
ID="rbSalesSize"
runat="server" >
<asp:ListItem Text="Less Than 50,000" />
<asp:ListItem Text="50,000 to 100,000" />
<asp:listitem Text="100,000 to 100" />
<asp:listItem text= "Over 50" /> </asp:radiobuttonlist></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><asp:button ID="Submit" OnClick="CheckLogin" runat="server" Text="Submit" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</form>
Hi DJ4UK,

I just found out the problem. The problem was in my Parameter.Add Declaration of @.City where I was not assigning the value of txtCity (should have been TxtCity.Text)

But now I get a Syntax error in INSERT INTO Statement:

System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

This seems to be a very simple insert statement. What could possibly be wrong here?
I just found out the solution to the second problem too. I was using a reserved word password in the Database and I had to use [] to resolve this.

Thanks for looking into my problem.

Diban

System.FormatException

Hi Guys,

When I trying to execute this code,

insGrupo = Nothing
insGrupo = New Grupo(Short.Parse(0), TxtGrCoCodi.Text)

occurs the following error

System.FormatException: Sequence of entrance was not in a incorrect format.

Somebody knows what it can be this error?

---------------
Marcus Vincius M. Montezanodid you get help with this?

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Marcus Vincius" <marc.marcus@.bol.com.br> wrote in message
news:%23M9qgFe1DHA.4032@.tk2msftngp13.phx.gbl...
> Hi Guys,
> When I trying to execute this code,
> insGrupo = Nothing
> insGrupo = New Grupo(Short.Parse(0), TxtGrCoCodi.Text)
>
> occurs the following error
> System.FormatException: Sequence of entrance was not in a incorrect
format.
>
> Somebody knows what it can be this error?
>
> ---------------
> Marcus Vincius M. Montezano

System.FormatException: Input string was not in a correct format.

Is this a bug or am I going crazy??
WILL NOT WORK: DateTime.Now.ToString("h")
THIS ONE WILL THOUGH: DateTime.Now.ToString(" h")
But that space gets put in front of the hour.
Anything with "h" will work, as long as it's not by itself ??Shouldn't it be "hh" ?

"hh" returns the hour with a zero in front if less than 10. "h" is supposed to return the hour without the zero.
DateTime.Now.ToString(" h")
that works, but it won't work if the space is not in front of the h.
Have you tried using string.Format to see if it gives you the same results?
Here's a good reference for the format strings:
http://www.stevex.org/CS/blogs/dottext/articles/158.aspx
If I think of anything else, I'll let you know.

M$ doesn't seem to want you to know the current hour without the 0 in front of it.
I triedString.Format("{0:h}", DateTime.Now) and it has the same problem that theDateTime.Now.ToString("h") method has.
For some reason, you cannot use "h" all by itself. Luckily the way I'm using it allows me to leave it as " h" (with a space in front).
I'm using it in a JavaScript file like so:
var curH = <%= DateTime.Now.ToString(" h") %>;
So, the JavaScript removes the space for me.
My guess is it's a bug. Thanks for you help anyways, but I'm not going to worry about it.

northflacomps wrote:

Is this a bug or am I going crazy??
WILL NOT WORK: DateTime.Now.ToString("h")
THIS ONE WILL THOUGH: DateTime.Now.ToString(" h")
But that space gets put in front of the hour.
Anything with "h" will work, as long as it's not by itself ??


Actually, that behaviour appears to be "by design" and is documented in the MSDN help.
"DateTimeFormatInfo Class... Only format patterns listed in the second table above [which is the table with h and H and so on] can be used to create custom patterns; standard format characters listed in the first table [which is a table with the abbreviation codes such as T => Long Time Pattern] cannot be used to create custom patterns. Custom patterns are at least two characters long"
It appears that since the standard patterns are sometimes single-characters in length, they decided to force custom patterns to be at least 2 characters in length, to avoid collisions and ambiguity. And so on.
For padding, when the desired custom format pattern is only one character long, they apparently want one to use the "%" sign.
Here is some sample code.

PrivateSub TestFormatStringButton_Click( _
ByVal senderAs System.Object, _
ByVal eAs System.EventArgs _
)Handles TestFormatStringButton.Click

'RTE: "Input string was not the correct format".
'Me.Response.Write(DateTime.Now.ToString("h"))

'RTE: "Input string was not in a correct format".
'Me.Response.Write(DateTime.Now.ToString("H"))

'RTE: "Format specifier was invalid".
'Me.Response.Write(DateTime.Now.Hour.ToString("H"))

'This works.
Me.Response.Write(DateTime.Now.ToString("%h"))

EndSub


HTH.
--Mark Kamoski


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctFormat.asp
h
Displays the hour as a number without leading zeros using the 12-hour clock (for example,1:15:15 PM). Use%h if this is the only character in your user-defined numeric format.
Thanks for that information. I looked at MSDN for the DateTime structure but didn't see anything about the "%". Seems kinda dumb to me.

System.FormatException: Input string was not in a correct format.

Strange error mblè mblè :)


Dim SQL = "SELECT confermato, confrndnum FROM utenti WHERE confermato = 'false' AND confrndnum = " & Qs
Dim RsCommand = New OleDbCommand(Sql, Conn)
Dim RsRecordCount = RsCommand.ExecuteScalar()

If RsRecordCount = 0 Then
divErrEx.Visible = True
Else
SQL = "UPDATE utenti SET confermato = 'true' WHERE ConfRndNum = " & QS
RsCommand = New OleDbCommand(Sql, Conn)
RsCommand.ExecuteNonQuery()
Dim ReadCookie = Request.Cookies("tristizia_auth")
ltrUsername.Text = ReadCookie("Username")
divConfOp.Visible = TRUE
End If


the line "If RsRecordCount = 0 Then" gives error
The error is strange becouse if RsRecordCount is 0 the page works, if not it gives the error

Thanks for any answer
Bye
. AtariVerify that the following line is not returning NULL. If it is and you are trying to put it into a string then it won't work of course. The line below is defiantely your problem I think though.


ltrUsername.Text = ReadCookie("Username")

Ok tryed, but the error appears =

I tryed either so:


If RsRecordCount = 0 Then
divErrEx.Visible = True
Else
SQL = "UPDATE utenti SET confermato = 'true' WHERE ConfRndNum = " & QS
RsCommand = New OleDbCommand(Sql, Conn)
RsCommand.ExecuteNonQuery()
Dim ReadCookie = Request.Cookies("tristizia_auth")
If Not ReadCookie Is Nothing Then
ltrUsername.Text = ReadCookie("Username")
Else
ltrUsername.Text = "[Unsknown]"
End If
divConfOp.Visible = TRUE
End If

But however I get error either so :


If RsRecordCount = 0 Then
divErrEx.Visible = True
Else
Dim MyVar = "ewruowehr"
End If

Boh?!?!

Bye
. Atari
One more victim of the Visual Basic type sloppiness (which is a feature).
Try to Dim ReadCookie as HttpCookie, just to be sure you don't get a string instead.
Uhm nothing is changed...


Dim Conn = New OleDbConnection("Provider = Microsoft.Jet.OleDb.4.0;Data Source=" & Server.MapPath("/mdb-database/tristizia.mdb"))
Conn.Open()
Dim SQL = "SELECT confermato, confrndnum FROM utenti WHERE confermato = 'false' AND confrndnum = " & Qs
Dim RsCommand = New OleDbCommand(Sql, Conn)
Dim RsRecordCount = RsCommand.ExecuteScalar()

<b style="color:red;">If RsRecordCount = 0 Then</b>
divErrEx.Visible = True
Else
SQL = "UPDATE utenti SET confermato = 'true' WHERE ConfRndNum = " & QS
RsCommand = New OleDbCommand(Sql, Conn)
RsCommand.ExecuteNonQuery()
Dim ReadCookie As HttpCookie = Request.Cookies("tristizia_auth")
If Not ReadCookie Is Nothing Then
ltrUsername.Text = ReadCookie("Username")
Else
ltrUsername.Text = "[Sconosciuto]"
End If
divConfOp.Visible = TRUE
End If

But what's the problem? I need to declare AS [type] the variables ? If so what's RsRecordCount ? I tryed As Integer but doesn't work...

Bye
. Atari
It's always better to declare the type of your variables. Not declaring it is a source of bugs.
Why do you use ExecuteScalar here, whereas your query returns two different columns? ExecuteScalar returns the first column of the first row. Here, it would be confermato. Is this column an integer?
In this case, you can Dim RsRecordCount as Integer = CType(RsCommand.ExecuteScalar(), Integer), but I suspect this is not what you're trying to do...
Your query should probably be "SELECT COUNT(*) FROM utenti WHERE confermato = 'false' AND confrndnum = " & Qs

System.FormatException: Input String was not in a correct format.

I've got an error "System.FormatException: Input string was not in a correct
format." while I'm implementing a datagrid and a textbox
What's wrong with it?

Sub Button1_Click(sender As Object, e As EventArgs)
DataGrid1.DataSource = MyQueryMethod(CInt(TextBox1.Text))
DataGrid1.DataBind()
End Sub

Function MyQueryMethod(ByVal others As String) As System.Data.DataSet
Dim connectionString As String = "server='localhost'; user id='******';
password='******'; database='******'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionStri ng)
Dim queryString As String = "SELECT [Software].* FROM [Software] WHERE
([Software].[Others] like @dotnet.itags.org.Others)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_others As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_others.ParameterName = "@dotnet.itags.org.Others" dbParam_others.Value = others
dbParam_others.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_others)

Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet

End FunctionI would guess it is something to do with converting the TextBox1.Text to an
int data type. The textbox could potentially contain a value other than a
numeric value. This would cause this error. Also, MyQueryMethod looks like
it is expecting a value of a string data type. Since you are converting
TextBox1.Text to an int type, this may also cause the error.

-Darrin

"sbox" <s@.b.x> wrote in message
news:%23ibArp48DHA.712@.tk2msftngp13.phx.gbl...
> I've got an error "System.FormatException: Input string was not in a
correct
> format." while I'm implementing a datagrid and a textbox
> What's wrong with it?
> Sub Button1_Click(sender As Object, e As EventArgs)
> DataGrid1.DataSource = MyQueryMethod(CInt(TextBox1.Text))
> DataGrid1.DataBind()
> End Sub
> Function MyQueryMethod(ByVal others As String) As System.Data.DataSet
> Dim connectionString As String = "server='localhost'; user
id='******';
> password='******'; database='******'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionStri ng)
> Dim queryString As String = "SELECT [Software].* FROM [Software] WHERE
> ([Software].[Others] like @.Others)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_others As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_others.ParameterName = "@.Others" dbParam_others.Value = others
> dbParam_others.DbType = System.Data.DbType.String
> dbCommand.Parameters.Add(dbParam_others)
> Dim dataAdapter As System.Data.IDbDataAdapter = New
> System.Data.SqlClient.SqlDataAdapter
> dataAdapter.SelectCommand = dbCommand
> Dim dataSet As System.Data.DataSet = New System.Data.DataSet
> dataAdapter.Fill(dataSet)
> Return dataSet
> End Function
You should not have the ' ' in your connection string. Take a look at the
connection strings at

http://www.able-consulting.com/dotn...ManagedProvider

Ben Miller

--
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

"sbox" <s@.b.x> wrote in message
news:%23ibArp48DHA.712@.tk2msftngp13.phx.gbl...
> I've got an error "System.FormatException: Input string was not in a
correct
> format." while I'm implementing a datagrid and a textbox
> What's wrong with it?
> Sub Button1_Click(sender As Object, e As EventArgs)
> DataGrid1.DataSource = MyQueryMethod(CInt(TextBox1.Text))
> DataGrid1.DataBind()
> End Sub
> Function MyQueryMethod(ByVal others As String) As System.Data.DataSet
> Dim connectionString As String = "server='localhost'; user
id='******';
> password='******'; database='******'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionStri ng)
> Dim queryString As String = "SELECT [Software].* FROM [Software] WHERE
> ([Software].[Others] like @.Others)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_others As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_others.ParameterName = "@.Others" dbParam_others.Value = others
> dbParam_others.DbType = System.Data.DbType.String
> dbCommand.Parameters.Add(dbParam_others)
> Dim dataAdapter As System.Data.IDbDataAdapter = New
> System.Data.SqlClient.SqlDataAdapter
> dataAdapter.SelectCommand = dbCommand
> Dim dataSet As System.Data.DataSet = New System.Data.DataSet
> dataAdapter.Fill(dataSet)
> Return dataSet
> End Function