Thursday, March 29, 2012
Newbie -- Page_Load( ) fires twice if image is added to Login page
I'm using Visual Studio 2005 + ASP.NET and C#
I have a login.aspx page with AutoEventWireup set to FALSE (also added to
top level Web.Config, and set to false)
With a "template" loginCtl the Page_Load( ) event fires once.
As soon as I add an ImageCtl or just drag an image using the designer, onto
the login page and then run it, I'm seeing the Page_Init( ) and Page_Load( )
functions being fired twice.
If I remove the image, then these methods are only fired once.
Any ideas?
I am setting the event delegate like this in my login.aspx.cs file:
protected override void OnInit( EventArgs e )
{
this.Load += new EventHandler( Page_Load );
}
protected void Page_Load( ... etc.
Thanks for any tips,
FrankThis isn't a direct answer, but I personally avoid that this.Load += new
EventHandler(Page_Load) stuff that the wizard puts in like the plague. The
reason being is that I subclass pages a lot, and when you depend on wiring
up events, you can run into issues where a subclass won't call the base
initializer, or the listeners get added in an order that prevents proper
handling (I'd have to dig up an example, but I had issues with Page_Load
never firing at all). Since you're overriding OnInit just to wire up an
event handler, I'd just override OnLoad and see if that might prevent the
double-hit (plus, you're plugging into the vtable instead of having to deal
with event firing/delegate calling)
Newbie -- Page_Load( ) fires twice if image is added to Login page
I'm using Visual Studio 2005 + ASP.NET and C#
I have a login.aspx page with AutoEventWireup set to FALSE (also added to
top level Web.Config, and set to false)
With a "template" loginCtl the Page_Load( ) event fires once.
As soon as I add an ImageCtl or just drag an image using the designer, onto
the login page and then run it, I'm seeing the Page_Init( ) and Page_Load( )
functions being fired twice.
If I remove the image, then these methods are only fired once.
Any ideas?
I am setting the event delegate like this in my login.aspx.cs file:
protected override void OnInit( EventArgs e )
{
this.Load += new EventHandler( Page_Load );
}
protected void Page_Load( ... etc.
Thanks for any tips,
FrankThis isn't a direct answer, but I personally avoid that this.Load += new
EventHandler(Page_Load) stuff that the wizard puts in like the plague. The
reason being is that I subclass pages a lot, and when you depend on wiring
up events, you can run into issues where a subclass won't call the base
initializer, or the listeners get added in an order that prevents proper
handling (I'd have to dig up an example, but I had issues with Page_Load
never firing at all). Since you're overriding OnInit just to wire up an
event handler, I'd just override OnLoad and see if that might prevent the
double-hit (plus, you're plugging into the vtable instead of having to deal
with event firing/delegate calling)
Saturday, March 24, 2012
Newbie help Webpage that pings servers and returns if it is up.
If it is up i want it to change an image to another image to tell me the server is down.
Can anyone help?You could use something like:
try { WebRequest test = WebRequest.Create("http://www.domain.com");
//display "up" image
} catch ( Exception e ) {
//display "down" image
}
For more information on System.Net.WebRequest use the link below (.NET Class Library) and in the left frame go to System.Net -> WebRequest.Hey thanx for the replay but im new to this stuff is there anyway you could give me a little more info?
Thursday, March 22, 2012
Newbie IMAGE SRC question
I basicly know how to pull a image down with using Image source in HTML. By
telling image src what file name to open. But if I have the file path stored
in a SQL database. such as c:/mypictures/myimagefile.gif, how would I call
that back up, to show that file with out typing the path in my code. Can I
just refrence the sql server, and read that file path? What would be the
correct way of writing that in my code. Or am I totally off base, and do
this an entirely diffrent way.
TIA!!!
RudyYou'll have to write code to pull the image form your database then write
it to the Response.OutputStream. I have a sample app that should get you
started:
http://staff.develop.com/ballen/blo.../>
aff48bf2481
-Brock
DevelopMentor
http://staff.develop.com/ballen
> Hello all!
> I basicly know how to pull a image down with using Image source in
> HTML. By telling image src what file name to open. But if I have the
> file path stored in a SQL database. such as
> c:/mypictures/myimagefile.gif, how would I call that back up, to show
> that file with out typing the path in my code. Can I just refrence
> the sql server, and read that file path? What would be the correct
> way of writing that in my code. Or am I totally off base, and do this
> an entirely diffrent way.
> TIA!!!
> Rudy
>
This article explains in detail how to pull files from a database and
display them dynamically to the user:
http://steveorr.net/articles/EasyUploads.aspx
This one explains how to generate images dynamically and display them to the
user:
http://steveorr.net/articles/ImproveYourImages.aspx
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Rudy" <Rudy@.discussions.microsoft.com> wrote in message
news:B76F371F-B5A7-42F4-BCAD-56FF560D8A99@.microsoft.com...
> Hello all!
> I basicly know how to pull a image down with using Image source in HTML.
> By
> telling image src what file name to open. But if I have the file path
> stored
> in a SQL database. such as c:/mypictures/myimagefile.gif, how would I call
> that back up, to show that file with out typing the path in my code. Can
> I
> just refrence the sql server, and read that file path? What would be the
> correct way of writing that in my code. Or am I totally off base, and do
> this an entirely diffrent way.
> TIA!!!
> Rudy
Hi Brock and Steve,
Thank you for the advise. I'll try it out tonite. I just want to make sure
I'm clear, I am not storing the image in the SQL db, just the filepath. Wil
l
this still work?
Thanks for your help!!!!
"Steve C. Orr [MVP, MCSD]" wrote:
> This article explains in detail how to pull files from a database and
> display them dynamically to the user:
> http://steveorr.net/articles/EasyUploads.aspx
> This one explains how to generate images dynamically and display them to t
he
> user:
> http://steveorr.net/articles/ImproveYourImages.aspx
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
> "Rudy" <Rudy@.discussions.microsoft.com> wrote in message
> news:B76F371F-B5A7-42F4-BCAD-56FF560D8A99@.microsoft.com...
>
>
It should be roughly similar.
The main difference would be that (instead of grabbing the bytes from a
database field) you'll probably be using Response.WriteFile.
Here's more info on Response.WriteFile
http://msdn.microsoft.com/library/d...tefiletopic.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Rudy" <Rudy@.discussions.microsoft.com> wrote in message
news:B91B851D-4A86-4A35-A6C2-F43ACC83E0A9@.microsoft.com...
> Hi Brock and Steve,
> Thank you for the advise. I'll try it out tonite. I just want to make
> sure
> I'm clear, I am not storing the image in the SQL db, just the filepath.
> Will
> this still work?
> Thanks for your help!!!!
> "Steve C. Orr [MVP, MCSD]" wrote:
>
Newbie IMAGE SRC question
I basicly know how to pull a image down with using Image source in HTML. By
telling image src what file name to open. But if I have the file path stored
in a SQL database. such as c:/mypictures/myimagefile.gif, how would I call
that back up, to show that file with out typing the path in my code. Can I
just refrence the sql server, and read that file path? What would be the
correct way of writing that in my code. Or am I totally off base, and do
this an entirely diffrent way.
TIA!!!
RudyYou'll have to write code to pull the image form your database then write
it to the Response.OutputStream. I have a sample app that should get you
started:
http://staff.develop.com/ballen/blo...f8-9aff48bf2481
-Brock
DevelopMentor
http://staff.develop.com/ballen
> Hello all!
> I basicly know how to pull a image down with using Image source in
> HTML. By telling image src what file name to open. But if I have the
> file path stored in a SQL database. such as
> c:/mypictures/myimagefile.gif, how would I call that back up, to show
> that file with out typing the path in my code. Can I just refrence
> the sql server, and read that file path? What would be the correct
> way of writing that in my code. Or am I totally off base, and do this
> an entirely diffrent way.
> TIA!!!
> Rudy
This article explains in detail how to pull files from a database and
display them dynamically to the user:
http://steveorr.net/articles/EasyUploads.aspx
This one explains how to generate images dynamically and display them to the
user:
http://steveorr.net/articles/ImproveYourImages.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Rudy" <Rudy@.discussions.microsoft.com> wrote in message
news:B76F371F-B5A7-42F4-BCAD-56FF560D8A99@.microsoft.com...
> Hello all!
> I basicly know how to pull a image down with using Image source in HTML.
> By
> telling image src what file name to open. But if I have the file path
> stored
> in a SQL database. such as c:/mypictures/myimagefile.gif, how would I call
> that back up, to show that file with out typing the path in my code. Can
> I
> just refrence the sql server, and read that file path? What would be the
> correct way of writing that in my code. Or am I totally off base, and do
> this an entirely diffrent way.
> TIA!!!
> Rudy
Hi Brock and Steve,
Thank you for the advise. I'll try it out tonite. I just want to make sure
I'm clear, I am not storing the image in the SQL db, just the filepath. Will
this still work?
Thanks for your help!!!!
"Steve C. Orr [MVP, MCSD]" wrote:
> This article explains in detail how to pull files from a database and
> display them dynamically to the user:
> http://steveorr.net/articles/EasyUploads.aspx
> This one explains how to generate images dynamically and display them to the
> user:
> http://steveorr.net/articles/ImproveYourImages.aspx
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
> "Rudy" <Rudy@.discussions.microsoft.com> wrote in message
> news:B76F371F-B5A7-42F4-BCAD-56FF560D8A99@.microsoft.com...
> > Hello all!
> > I basicly know how to pull a image down with using Image source in HTML.
> > By
> > telling image src what file name to open. But if I have the file path
> > stored
> > in a SQL database. such as c:/mypictures/myimagefile.gif, how would I call
> > that back up, to show that file with out typing the path in my code. Can
> > I
> > just refrence the sql server, and read that file path? What would be the
> > correct way of writing that in my code. Or am I totally off base, and do
> > this an entirely diffrent way.
> > TIA!!!
> > Rudy
>
It should be roughly similar.
The main difference would be that (instead of grabbing the bytes from a
database field) you'll probably be using Response.WriteFile.
Here's more info on Response.WriteFile
http://msdn.microsoft.com/library/d...tefiletopic.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Rudy" <Rudy@.discussions.microsoft.com> wrote in message
news:B91B851D-4A86-4A35-A6C2-F43ACC83E0A9@.microsoft.com...
> Hi Brock and Steve,
> Thank you for the advise. I'll try it out tonite. I just want to make
> sure
> I'm clear, I am not storing the image in the SQL db, just the filepath.
> Will
> this still work?
> Thanks for your help!!!!
> "Steve C. Orr [MVP, MCSD]" wrote:
>> This article explains in detail how to pull files from a database and
>> display them dynamically to the user:
>> http://steveorr.net/articles/EasyUploads.aspx
>>
>> This one explains how to generate images dynamically and display them to
>> the
>> user:
>> http://steveorr.net/articles/ImproveYourImages.aspx
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>> "Rudy" <Rudy@.discussions.microsoft.com> wrote in message
>> news:B76F371F-B5A7-42F4-BCAD-56FF560D8A99@.microsoft.com...
>> > Hello all!
>>> > I basicly know how to pull a image down with using Image source in
>> > HTML.
>> > By
>> > telling image src what file name to open. But if I have the file path
>> > stored
>> > in a SQL database. such as c:/mypictures/myimagefile.gif, how would I
>> > call
>> > that back up, to show that file with out typing the path in my code.
>> > Can
>> > I
>> > just refrence the sql server, and read that file path? What would be
>> > the
>> > correct way of writing that in my code. Or am I totally off base, and
>> > do
>> > this an entirely diffrent way.
>>> > TIA!!!
>>> > Rudy
>>
>>
>
Newbie image question.
Phil.
Phil Winstanley [Microsoft MVP ASP.NET] wrote:
> Jensen,
> Here's an article that Dino Esperante wrote on the subject: -
> http://www.ftponline.com/vsm/2002_0...ttips/esposito/
> Hth,
> Phil Winstanley
> Microsoft ASP.NET MVP
> http://www.myservicescentral.comThank you...
"Phil Winstanley [Microsoft MVP ASP.NET]" <phil@.winstanley.name> wrote in
message news:caepln$c1s@.odbk17.prod.google.com...
> Dino Esposito rather! :-) Sorry Dino!
> Phil.
> Phil Winstanley [Microsoft MVP ASP.NET] wrote:
> > Jensen,
> > Here's an article that Dino Esperante wrote on the subject: -
> > http://www.ftponline.com/vsm/2002_0...ttips/esposito/
> > Hth,
> > Phil Winstanley
> > Microsoft ASP.NET MVP
> > http://www.myservicescentral.com
Newbie image question.
asp.net web form?
I assume the image need not to be scaled.On Sat, 12 Jun 2004 03:38:37 +0200, Jensen bredal
<jensen.bredal@.mimosa.com> wrote:
> How do i display an image stored in a database in an
> asp.net web form?
> I assume the image need not to be scaled.
For some reason, I couldn't find a simpler example than this:
http://www.codeproject.com/aspnet/image_asp.asp
Check out the latter part of the article, view.aspx is what you're looking
for. The only thing is the author created a custom class for DB
interaction, don't let it confuse you in the code. The DB access code is
above the section I'm referring to.
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
On Sat, 12 Jun 2004 20:58:36 -0500, Craig Deelsnyder
<cdeelsny@.no_spam_4_meyahoo.com> wrote:
> On Sat, 12 Jun 2004 03:38:37 +0200, Jensen bredal
> <jensen.bredal@.mimosa.com> wrote:
>> How do i display an image stored in a database in an
>> asp.net web form?
>>
>> I assume the image need not to be scaled.
>>
>>
> For some reason, I couldn't find a simpler example than this:
> http://www.codeproject.com/aspnet/image_asp.asp
> Check out the latter part of the article, view.aspx is what you're
> looking for. The only thing is the author created a custom class for DB
> interaction, don't let it confuse you in the code. The DB access code
> is above the section I'm referring to.
dang, sorry for the extra reply...my newsreader broke the thread and i
didn't notice...
enjoy...
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Well that example was great too. But i have noticed two things compare with
previous link i got.
The example here does not tell you how to display the image from a datagrid
as an example.
And other thing that is common to both example is that the
response.ContenType is not set from a value in database.
Im my code i also do store Response.ContentType and
that should lead to the following:
Response.ContentType = dr[ImageContentType].ToString();
where dr is the datarow containing my image info.
Many thanks
"Craig Deelsnyder" <cdeelsny@.no_spam_4_meyahoo.com> wrote in message
news:opr9if21dg75dg5d@.tux...
> On Sat, 12 Jun 2004 20:58:36 -0500, Craig Deelsnyder
> <cdeelsny@.no_spam_4_meyahoo.com> wrote:
> > On Sat, 12 Jun 2004 03:38:37 +0200, Jensen bredal
> > <jensen.bredal@.mimosa.com> wrote:
> >> How do i display an image stored in a database in an
> >> asp.net web form?
> >>
> >> I assume the image need not to be scaled.
> >>
> >>
> > For some reason, I couldn't find a simpler example than this:
> > http://www.codeproject.com/aspnet/image_asp.asp
> > Check out the latter part of the article, view.aspx is what you're
> > looking for. The only thing is the author created a custom class for DB
> > interaction, don't let it confuse you in the code. The DB access code
> > is above the section I'm referring to.
> dang, sorry for the extra reply...my newsreader broke the thread and i
> didn't notice...
> enjoy...
> --
> Craig Deelsnyder
> Microsoft MVP - ASP/ASP.NET
Newbie image question.
asp.net web form?
I assume the image need not to be scaled.Jensen,
Here's an article that Dino Esperante wrote on the subject: -
http://www.ftponline.com/vsm/2002_0...ttips/esposito/
Hth,
Phil Winstanley
Microsoft ASP.NET MVP
http://www.myservicescentral.com
Dino Esposito rather! :-) Sorry Dino!
Phil.
Phil Winstanley [Microsoft MVP ASP.NET] wrote:
> Jensen,
> Here's an article that Dino Esperante wrote on the subject: -
> http://www.ftponline.com/vsm/2002_0...ttips/esposito/
> Hth,
> Phil Winstanley
> Microsoft ASP.NET MVP
> http://www.myservicescentral.com
Thank you...
"Phil Winstanley [Microsoft MVP ASP.NET]" <phil@.winstanley.name> wrote i
n
message news:caepln$c1s@.odbk17.prod.google.com...
> Dino Esposito rather! :-) Sorry Dino!
> Phil.
> Phil Winstanley [Microsoft MVP ASP.NET] wrote:
>
On Sat, 12 Jun 2004 03:38:37 +0200, Jensen bredal
<jensen.bredal@.mimosa.com> wrote:
> How do i display an image stored in a database in an
> asp.net web form?
> I assume the image need not to be scaled.
>
For some reason, I couldn't find a simpler example than this:
http://www.codeproject.com/aspnet/image_asp.asp
Check out the latter part of the article, view.aspx is what you're looking
for. The only thing is the author created a custom class for DB
interaction, don't let it confuse you in the code. The DB access code is
above the section I'm referring to.
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
On Sat, 12 Jun 2004 20:58:36 -0500, Craig Deelsnyder
<cdeelsny@.no_spam_4_meyahoo.com> wrote:
> On Sat, 12 Jun 2004 03:38:37 +0200, Jensen bredal
> <jensen.bredal@.mimosa.com> wrote:
>
> For some reason, I couldn't find a simpler example than this:
> http://www.codeproject.com/aspnet/image_asp.asp
> Check out the latter part of the article, view.aspx is what you're
> looking for. The only thing is the author created a custom class for DB
> interaction, don't let it confuse you in the code. The DB access code
> is above the section I'm referring to.
>
dang, sorry for the extra reply...my newsreader broke the thread and i
didn't notice...
enjoy...
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Well that example was great too. But i have noticed two things compare with
previous link i got.
The example here does not tell you how to display the image from a datagrid
as an example.
And other thing that is common to both example is that the
response.ContenType is not set from a value in database.
Im my code i also do store Response.ContentType and
that should lead to the following:
Response.ContentType = dr[ImageContentType].ToString();
where dr is the datarow containing my image info.
Many thanks
"Craig Deelsnyder" <cdeelsny@.no_spam_4_meyahoo.com> wrote in message
news:opr9if21dg75dg5d@.tux...
> On Sat, 12 Jun 2004 20:58:36 -0500, Craig Deelsnyder
> <cdeelsny@.no_spam_4_meyahoo.com> wrote:
>
> dang, sorry for the extra reply...my newsreader broke the thread and i
> didn't notice...
> enjoy...
> --
> Craig Deelsnyder
> Microsoft MVP - ASP/ASP.NET