Thursday, March 29, 2012
newbie: load image from db + Repeater
asp.net 2.0
With the help of a Repeater control on my webpage I want to dynamically
generate a list which contains both images and text field. This data are
stored in the aspnetdb.mdf database.
I know it's possible to have the imag tag to point to a .aspx file (<img
src="getImage.aspx" /> )
This is the Page_Load event I have in my getImage.aspx file
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}
}
The getImage.aspx file above is used another place in my project. My PROBLEM
is that I don't know how to adapt (make another version of getImage.aspx
which suit the repeater) this getImage.aspx file into the Repeater control.
More specific: in the Page_Load event of getImage.aspx you see that I'm
setting some properties of the Response object with some values of the
Profile object. But in the new getImage.aspx file (created specially for the
Repeater control) I must for each line in the Repeater control pass over the
correct ID to the Page_Load event so the getImage.aspx file knows what image
to load!
In other words how can I tell the Page_Load event what image to show. I
think about using a paramter. But my problem is that I don't know how to add
such a parameter. Maybe it could be passed in the EventArgs argument.. I'm
not sure...
Instead of sending the picture ID I could send over the bytes representing
the image. But even that, I (As Far As I Know) still have to send a paramter
to the Page_Load event
Any ideas how I should pass over such a parameter?
Jeffhello Jeff
you can track the id's and do something like getImage ( id ) in the
ItemDataBound event.
on this page is a similar example, though uses a GridView instead, but
logically it's the same
http://authors.aspalliance.com/aspx...te.aspx
Monday, March 26, 2012
newbie: load image from db + Repeater
asp.net 2.0
With the help of a Repeater control on my webpage I want to dynamically
generate a list which contains both images and text field. This data are
stored in the aspnetdb.mdf database.
I know it's possible to have the imag tag to point to a .aspx file (<img
src="getImage.aspx" />)
This is the Page_Load event I have in my getImage.aspx file
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}
}
The getImage.aspx file above is used another place in my project. My PROBLEM
is that I don't know how to adapt (make another version of getImage.aspx
which suit the repeater) this getImage.aspx file into the Repeater control.
More specific: in the Page_Load event of getImage.aspx you see that I'm
setting some properties of the Response object with some values of the
Profile object. But in the new getImage.aspx file (created specially for the
Repeater control) I must for each line in the Repeater control pass over the
correct ID to the Page_Load event so the getImage.aspx file knows what image
to load!
In other words how can I tell the Page_Load event what image to show. I
think about using a paramter. But my problem is that I don't know how to add
such a parameter. Maybe it could be passed in the EventArgs argument.. I'm
not sure...
Instead of sending the picture ID I could send over the bytes representing
the image. But even that, I (As Far As I Know) still have to send a paramter
to the Page_Load event
Any ideas how I should pass over such a parameter?
Jeffhello Jeff
you can track the id's and do something like getImage ( id ) in the
ItemDataBound event.
on this page is a similar example, though uses a GridView instead, but
logically it's the same
http://authors.aspalliance.com/aspx...inaryWrite.aspx
NEWBIE: passing error to javascript alert
is there a way call a javascript function directly from within asp
page?
Example, here is page load event in C#
protected void Page_Load(object sender, EventArgs e){
// create error
int Var0 = 0;
try {
int iVar1 = 8/Var0;
}
catch (Exception ex){
string sExMsg = ex.Message;
//javascript works fine with string constant
Response.Write("<script type='text/javascript'>alert('In Catch');</
script>");
//can write error to page no problem
Response.Write(sExMsg);
// would like a popup with error
Response.Write("<script language='javascript'>doAlert(" + sExMsg +
");</script>");
Response.Write("<script language='javascript'>function doAlert(sExMsg)
{alert(sExMsg);}</script>");
//write error to log since I can't pop-it-up
//StreamWriter sw = File.AppendText(Server.MapPath("~/error.log"));
//sw.WriteLine(sExMsg);
//sw.Close();
}
}
Any help for a newbie is appreciated
Gi<gijeet@.yahoo.comwrote in message
news:1193076186.658316.66870@.e9g2000prf.googlegrou ps.com...
Quote:
Originally Posted by
Any help for a newbie is appreciated
ClientScript.RegisterStartupScript(GetType(), "error", "alert('In Catch');",
true);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
ClientScript.RegisterStartupScript(GetType(), "error", "alert('In Catch');",
Quote:
Originally Posted by
true);
Thanks but not sure how to use this. Where do I put this? class
level before page load event? within page load? do I need a
RegisterStartupScript for each alert I wish to use?
Gi
<gijeet@.yahoo.comwrote in message
news:1193079485.948563.150590@.i38g2000prf.googlegr oups.com...
Quote:
Originally Posted by
Quote:
Originally Posted by
>ClientScript.RegisterStartupScript(GetType(), "error", "alert('In
>Catch');",
>true);
>
Thanks but not sure how to use this. Where do I put this?
Wherever you like, so long as you don't Redirect from the page...
Basically, it will send down the JavaScript to run after the page had
loaded...
Quote:
Originally Posted by
do I need a RegisterStartupScript for each alert I wish to use?
Yes.
Incidentally, why are you actually doing this...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Incidentally, why are you actually doing this...?
basically for debugging. I don't like response.writes and I'm trying
to learn javascript. but if you know of a better way to popup alerts,
let me know.
use the debugger to debug. alert debugging is asp classic style :)
"gijeet@.yahoo.com" wrote:
Quote:
Originally Posted by
Quote:
Originally Posted by
Incidentally, why are you actually doing this...?
basically for debugging. I don't like response.writes and I'm trying
to learn javascript. but if you know of a better way to popup alerts,
let me know.
>
>
>
>
>
>
This can help you:
How to Pass Messages and Actions between Server and Client
http://usableasp.net/DeveloperPage...erAndClient.htm
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<gijeet@.yahoo.comwrote in message
news:1193076186.658316.66870@.e9g2000prf.googlegrou ps.com...
Quote:
Originally Posted by
Hello,
is there a way call a javascript function directly from within asp
page?
Example, here is page load event in C#
>
protected void Page_Load(object sender, EventArgs e){
>
// create error
int Var0 = 0;
try {
int iVar1 = 8/Var0;
}
>
catch (Exception ex){
>
string sExMsg = ex.Message;
>
>
//javascript works fine with string constant
Response.Write("<script type='text/javascript'>alert('In Catch');</
script>");
>
//can write error to page no problem
Response.Write(sExMsg);
>
// would like a popup with error
Response.Write("<script language='javascript'>doAlert(" + sExMsg +
");</script>");
Response.Write("<script language='javascript'>function doAlert(sExMsg)
{alert(sExMsg);}</script>");
>
//write error to log since I can't pop-it-up
//StreamWriter sw = File.AppendText(Server.MapPath("~/error.log"));
//sw.WriteLine(sExMsg);
//sw.Close();
>
}
>
}
>
Any help for a newbie is appreciated
>
Gi
>
"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@.mMvVpPsS.orgwrote in
message news:%23DynzGXFIHA.4880@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
This can help you:
How to Pass Messages and Actions between Server and Client
http://usableasp.net/DeveloperPage...erAndClient.htm
Not much use in this particular case, though, as the OP's requirements for
this were for debugging a la ASP Classic...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Friday, March 16, 2012
Newly added asp.net webforms cannot parse
I simply try to add new default webforms to my project and none of them
can load.
Has anybody received an error like this?
Thanks,
Do
Parser Error
Description: An error occurred during the parsing of a resource required to
service this request. Please review the following specific parse error
details and modify your source file appropriately.
Parser Error Message: Could not load type 'nspi1.WebForm3'.
Source Error:
Line 1: <%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm3.aspx.vb" Inherits="nspi1.WebForm3"%>
Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Line 3: <html
Source File: c:\hosting\webhost4life\member\userb\nspi1.3\WebFo rm3.aspx
Line: 1
-----------------------
--
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573Hi,
Try to rebuild the project and re-load the page in the browser. You might be
having this error as the page class the newly added page inherits from in
its @.Page directive has not been compiled into the code-behind assembly.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Do" <doduong12141214@.hotmail.com> wrote in message
news:e%23KSrMFmDHA.2676@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I simply try to add new default webforms to my project and none of them
> can load.
> Has anybody received an error like this?
> Thanks,
> Do
> Parser Error
> Description: An error occurred during the parsing of a resource required
to
> service this request. Please review the following specific parse error
> details and modify your source file appropriately.
> Parser Error Message: Could not load type 'nspi1.WebForm3'.
> Source Error:
> Line 1: <%@. Page Language="vb" AutoEventWireup="false"
> Codebehind="WebForm3.aspx.vb" Inherits="nspi1.WebForm3"%>
> Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> Line 3: <html>
> Source File: c:\hosting\webhost4life\member\userb\nspi1.3\WebFo rm3.aspx
> Line: 1
>
> -----------------------
--
> --
> Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET
> Version:1.1.4322.573
Hi,
Try to rebuild the project and re-load the page in the browser. You might be
having this error as the page class the newly added page inherits from in
its @.Page directive has not been compiled into the code-behind assembly.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Do" <doduong12141214@.hotmail.com> wrote in message
news:e%23KSrMFmDHA.2676@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I simply try to add new default webforms to my project and none of them
> can load.
> Has anybody received an error like this?
> Thanks,
> Do
> Parser Error
> Description: An error occurred during the parsing of a resource required
to
> service this request. Please review the following specific parse error
> details and modify your source file appropriately.
> Parser Error Message: Could not load type 'nspi1.WebForm3'.
> Source Error:
> Line 1: <%@. Page Language="vb" AutoEventWireup="false"
> Codebehind="WebForm3.aspx.vb" Inherits="nspi1.WebForm3"%>
> Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> Line 3: <html>
> Source File: c:\hosting\webhost4life\member\userb\nspi1.3\WebFo rm3.aspx
> Line: 1
>
> -----------------------
--
> --
> Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET
> Version:1.1.4322.573