saving picture to a user profile!

J

Jeff

Hey

(and thank you for reading my post)

In visual web developer 2005 express edition I've created a simple website
project..

At this website I want users who register to be able to upload a picture of
themselves to their profile... I admit that I'm a newbie... but this is how
I understand this:

I create a new section in web.config contain this info
<profile defaultProvider="AspNetSqlProfileProvider">
<properties>
<add name="Name" />
<add name="Picture" type="System.Web.UI.WebControls.Image" />
</properties>
</profile>

Then in the code I can write something like this:

Profile.Picture = <a picture>;

And then during execution of this code the picture is automatically saved in
the express database visual web developer 2005 express edition created in
this project folder. (the .NET framework creates the new column in the user
profile and do all functionality for saving & loading the image from the db)

Is it how it works???

Hmm it can't be correct, because even now I can create new users to my
website, name & password being used by the login control in my website...
but all the data my web.config file has is this:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/></system.web>
</configuration>
There are no settings here that hold the username and password..... so
clearly what I suggest above must be wrong!

Please guide me on the right track here, give me some clue I could look
after... a link explaining this would be great (I've been google already,
but I think I'm searching with the wrong keywords)

Please, I'm stucked in this, so some suggestions would be greatly
appreaciated!

Jeff
 
N

neilmcguigan

hey jeff

you'll likely want to store the picture as a byte array in the profile

images in html are not embedded in the html itself, but are references
to external files, so you'll have to create another url that serves up
the images.

in your web.config:

<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null"
/>
<add name="PictureType" type="string" />
</properties>
</profile>

your upload page could be like this:

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />

with this in the code behind (C#):

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;

byte[] data = new byte[file.ContentLength];

file.InputStream.Read(data, 0, file.ContentLength);

Profile.Picture = data;
Profile.PictureType = file.ContentType;
}

your "getImage.aspx" page like this (C#):

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

and your page that you want to host the image on, like this:

<img src="getImage.aspx" />

HTH

Neil
 
J

Jeff

Hey

Thank you very much for your help, I've almost solved this now.

However I've run into a little problem:
When I run this app I get this exception:
"The property 'Picture' could not be created from it's default value. Error
message"

I get this error when the picture property is null

Here is my code (I'm using the same webpage to view the image and select the
image):

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

public partial class webForms_Profile_photo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;
byte[] data = new byte[file.ContentLength];
file.InputStream.Read(data, 0, file.ContentLength);
Profile.Picture = data;
Profile.PictureType = file.ContentType;
}
}

Any ideas on how to solve this?

Jeff





hey jeff

you'll likely want to store the picture as a byte array in the profile

images in html are not embedded in the html itself, but are references
to external files, so you'll have to create another url that serves up
the images.

in your web.config:

<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null"
/>
<add name="PictureType" type="string" />
</properties>
</profile>

your upload page could be like this:

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />

with this in the code behind (C#):

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;

byte[] data = new byte[file.ContentLength];

file.InputStream.Read(data, 0, file.ContentLength);

Profile.Picture = data;
Profile.PictureType = file.ContentType;
}

your "getImage.aspx" page like this (C#):

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

and your page that you want to host the image on, like this:

<img src="getImage.aspx" />

HTH

Neil

Hey

(and thank you for reading my post)

In visual web developer 2005 express edition I've created a simple
website
project..

At this website I want users who register to be able to upload a picture
of
themselves to their profile... I admit that I'm a newbie... but this is
how
I understand this:

I create a new section in web.config contain this info
<profile defaultProvider="AspNetSqlProfileProvider">
<properties>
<add name="Name" />
<add name="Picture" type="System.Web.UI.WebControls.Image" />
</properties>
</profile>

Then in the code I can write something like this:

Profile.Picture = <a picture>;

And then during execution of this code the picture is automatically saved
in
the express database visual web developer 2005 express edition created in
this project folder. (the .NET framework creates the new column in the
user
profile and do all functionality for saving & loading the image from the
db)

Is it how it works???

Hmm it can't be correct, because even now I can create new users to my
website, name & password being used by the login control in my website...
but all the data my web.config file has is this:
<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/></system.web>
</configuration>
There are no settings here that hold the username and password..... so
clearly what I suggest above must be wrong!

Please guide me on the right track here, give me some clue I could look
after... a link explaining this would be great (I've been google already,
but I think I'm searching with the wrong keywords)

Please, I'm stucked in this, so some suggestions would be greatly
appreaciated!

Jeff
 
N

neilmcguigan

hey jeff

the part with Response.BinaryWrite has to be in a different page, in
this case GetFile.aspx

you should also check for null:

if(Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

cheers

neil
Hey

Thank you very much for your help, I've almost solved this now.

However I've run into a little problem:
When I run this app I get this exception:
"The property 'Picture' could not be created from it's default value. Error
message"

I get this error when the picture property is null

Here is my code (I'm using the same webpage to view the image and select the
image):

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

public partial class webForms_Profile_photo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;
byte[] data = new byte[file.ContentLength];
file.InputStream.Read(data, 0, file.ContentLength);
Profile.Picture = data;
Profile.PictureType = file.ContentType;
}
}

Any ideas on how to solve this?

Jeff





hey jeff

you'll likely want to store the picture as a byte array in the profile

images in html are not embedded in the html itself, but are references
to external files, so you'll have to create another url that serves up
the images.

in your web.config:

<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null"
/>
<add name="PictureType" type="string" />
</properties>
</profile>

your upload page could be like this:

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />

with this in the code behind (C#):

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;

byte[] data = new byte[file.ContentLength];

file.InputStream.Read(data, 0, file.ContentLength);

Profile.Picture = data;
Profile.PictureType = file.ContentType;
}

your "getImage.aspx" page like this (C#):

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

and your page that you want to host the image on, like this:

<img src="getImage.aspx" />

HTH

Neil

Hey

(and thank you for reading my post)

In visual web developer 2005 express edition I've created a simple
website
project..

At this website I want users who register to be able to upload a picture
of
themselves to their profile... I admit that I'm a newbie... but this is
how
I understand this:

I create a new section in web.config contain this info
<profile defaultProvider="AspNetSqlProfileProvider">
<properties>
<add name="Name" />
<add name="Picture" type="System.Web.UI.WebControls.Image" />
</properties>
</profile>

Then in the code I can write something like this:

Profile.Picture = <a picture>;

And then during execution of this code the picture is automatically saved
in
the express database visual web developer 2005 express edition created in
this project folder. (the .NET framework creates the new column in the
user
profile and do all functionality for saving & loading the image from the
db)

Is it how it works???

Hmm it can't be correct, because even now I can create new users to my
website, name & password being used by the login control in my website...
but all the data my web.config file has is this:
<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/></system.web>
</configuration>
There are no settings here that hold the username and password..... so
clearly what I suggest above must be wrong!

Please guide me on the right track here, give me some clue I could look
after... a link explaining this would be great (I've been google already,
but I think I'm searching with the wrong keywords)

Please, I'm stucked in this, so some suggestions would be greatly
appreaciated!

Jeff
 
J

Jeff

Hey


My code crashes:

This is the error message I get:
"The property 'Picture' could not be created from it's default value. Error
message: There is an error in XML document (1, 1)."

(The crash occur in public class ProfileCommon :
System.Web.Profile.ProfileBase, see code below):

public virtual byte[] Picture {
get {
return ((byte[])(this.GetPropertyValue("Picture")));
}
set {
this.SetPropertyValue("Picture", value);
}
}

This is my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null"
/>
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>


Any ideas what I should do to fix this problem?... I thought about setting
another image as default value, but then the image had to be converted to
xml and placed in web.config. And maybe if I use a default image it wouldn't
solve the problem either -> maybe the error occur because of a error in
web.config?

any ideas?


hey jeff

the part with Response.BinaryWrite has to be in a different page, in
this case GetFile.aspx

you should also check for null:

if(Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

cheers

neil
Hey

Thank you very much for your help, I've almost solved this now.

However I've run into a little problem:
When I run this app I get this exception:
"The property 'Picture' could not be created from it's default value.
Error
message"

I get this error when the picture property is null

Here is my code (I'm using the same webpage to view the image and select
the
image):

<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

public partial class webForms_Profile_photo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;
byte[] data = new byte[file.ContentLength];
file.InputStream.Read(data, 0, file.ContentLength);
Profile.Picture = data;
Profile.PictureType = file.ContentType;
}
}

Any ideas on how to solve this?

Jeff





hey jeff

you'll likely want to store the picture as a byte array in the profile

images in html are not embedded in the html itself, but are references
to external files, so you'll have to create another url that serves up
the images.

in your web.config:

<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null"
/>
<add name="PictureType" type="string" />
</properties>
</profile>

your upload page could be like this:

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />

with this in the code behind (C#):

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;

byte[] data = new byte[file.ContentLength];

file.InputStream.Read(data, 0, file.ContentLength);

Profile.Picture = data;
Profile.PictureType = file.ContentType;
}

your "getImage.aspx" page like this (C#):

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

and your page that you want to host the image on, like this:

<img src="getImage.aspx" />

HTH

Neil


Jeff wrote:
Hey

(and thank you for reading my post)

In visual web developer 2005 express edition I've created a simple
website
project..

At this website I want users who register to be able to upload a
picture
of
themselves to their profile... I admit that I'm a newbie... but this
is
how
I understand this:

I create a new section in web.config contain this info
<profile defaultProvider="AspNetSqlProfileProvider">
<properties>
<add name="Name" />
<add name="Picture" type="System.Web.UI.WebControls.Image" />
</properties>
</profile>

Then in the code I can write something like this:

Profile.Picture = <a picture>;

And then during execution of this code the picture is automatically
saved
in
the express database visual web developer 2005 express edition created
in
this project folder. (the .NET framework creates the new column in the
user
profile and do all functionality for saving & loading the image from
the
db)

Is it how it works???

Hmm it can't be correct, because even now I can create new users to my
website, name & password being used by the login control in my
website...
but all the data my web.config file has is this:
<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/></system.web>
</configuration>
There are no settings here that hold the username and password..... so
clearly what I suggest above must be wrong!

Please guide me on the right track here, give me some clue I could
look
after... a link explaining this would be great (I've been google
already,
but I think I'm searching with the wrong keywords)

Please, I'm stucked in this, so some suggestions would be greatly
appreaciated!

Jeff
 
N

neilmcguigan

why are you doing it that way? thx

Hey


My code crashes:

This is the error message I get:
"The property 'Picture' could not be created from it's default value. Error
message: There is an error in XML document (1, 1)."

(The crash occur in public class ProfileCommon :
System.Web.Profile.ProfileBase, see code below):

public virtual byte[] Picture {
get {
return ((byte[])(this.GetPropertyValue("Picture")));
}
set {
this.SetPropertyValue("Picture", value);
}
}

This is my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null"
/>
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>


Any ideas what I should do to fix this problem?... I thought about setting
another image as default value, but then the image had to be converted to
xml and placed in web.config. And maybe if I use a default image it wouldn't
solve the problem either -> maybe the error occur because of a error in
web.config?

any ideas?


hey jeff

the part with Response.BinaryWrite has to be in a different page, in
this case GetFile.aspx

you should also check for null:

if(Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

cheers

neil
Hey

Thank you very much for your help, I've almost solved this now.

However I've run into a little problem:
When I run this app I get this exception:
"The property 'Picture' could not be created from it's default value.
Error
message"

I get this error when the picture property is null

Here is my code (I'm using the same webpage to view the image and select
the
image):

<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

public partial class webForms_Profile_photo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;
byte[] data = new byte[file.ContentLength];
file.InputStream.Read(data, 0, file.ContentLength);
Profile.Picture = data;
Profile.PictureType = file.ContentType;
}
}

Any ideas on how to solve this?

Jeff





hey jeff

you'll likely want to store the picture as a byte array in the profile

images in html are not embedded in the html itself, but are references
to external files, so you'll have to create another url that serves up
the images.

in your web.config:

<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null"
/>
<add name="PictureType" type="string" />
</properties>
</profile>

your upload page could be like this:

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />

with this in the code behind (C#):

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;

byte[] data = new byte[file.ContentLength];

file.InputStream.Read(data, 0, file.ContentLength);

Profile.Picture = data;
Profile.PictureType = file.ContentType;
}

your "getImage.aspx" page like this (C#):

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

and your page that you want to host the image on, like this:

<img src="getImage.aspx" />

HTH

Neil


Jeff wrote:
Hey

(and thank you for reading my post)

In visual web developer 2005 express edition I've created a simple
website
project..

At this website I want users who register to be able to upload a
picture
of
themselves to their profile... I admit that I'm a newbie... but this
is
how
I understand this:

I create a new section in web.config contain this info
<profile defaultProvider="AspNetSqlProfileProvider">
<properties>
<add name="Name" />
<add name="Picture" type="System.Web.UI.WebControls.Image" />
</properties>
</profile>

Then in the code I can write something like this:

Profile.Picture = <a picture>;

And then during execution of this code the picture is automatically
saved
in
the express database visual web developer 2005 express edition created
in
this project folder. (the .NET framework creates the new column in the
user
profile and do all functionality for saving & loading the image from
the
db)

Is it how it works???

Hmm it can't be correct, because even now I can create new users to my
website, name & password being used by the login control in my
website...
but all the data my web.config file has is this:
<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/></system.web>
</configuration>
There are no settings here that hold the username and password..... so
clearly what I suggest above must be wrong!

Please guide me on the right track here, give me some clue I could
look
after... a link explaining this would be great (I've been google
already,
but I think I'm searching with the wrong keywords)

Please, I'm stucked in this, so some suggestions would be greatly
appreaciated!

Jeff
 
J

Jeff

Hey

Thank you for taking the time to respond to my post here on this forum.

I removed the defaultValue from the "picture" property in web.config. Then I
realized that I have to use 2 webpages. 1 webpage (page A) to read in the
image.... and another webpage (page B) that displays the result of page A...

Thanks!






why are you doing it that way? thx

Hey


My code crashes:

This is the error message I get:
"The property 'Picture' could not be created from it's default value.
Error
message: There is an error in XML document (1, 1)."

(The crash occur in public class ProfileCommon :
System.Web.Profile.ProfileBase, see code below):

public virtual byte[] Picture {
get {
return ((byte[])(this.GetPropertyValue("Picture")));
}
set {
this.SetPropertyValue("Picture", value);
}
}

This is my web.config file:
<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]"
defaultValue="null"
/>
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>


Any ideas what I should do to fix this problem?... I thought about
setting
another image as default value, but then the image had to be converted to
xml and placed in web.config. And maybe if I use a default image it
wouldn't
solve the problem either -> maybe the error occur because of a error in
web.config?

any ideas?


hey jeff

the part with Response.BinaryWrite has to be in a different page, in
this case GetFile.aspx

you should also check for null:

if(Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

cheers

neil

Jeff wrote:
Hey

Thank you very much for your help, I've almost solved this now.

However I've run into a little problem:
When I run this app I get this exception:
"The property 'Picture' could not be created from it's default value.
Error
message"

I get this error when the picture property is null

Here is my code (I'm using the same webpage to view the image and
select
the
image):

<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" defaultValue="null" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

public partial class webForms_Profile_photo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;
byte[] data = new byte[file.ContentLength];
file.InputStream.Read(data, 0, file.ContentLength);
Profile.Picture = data;
Profile.PictureType = file.ContentType;
}
}

Any ideas on how to solve this?

Jeff





hey jeff

you'll likely want to store the picture as a byte array in the
profile

images in html are not embedded in the html itself, but are
references
to external files, so you'll have to create another url that serves
up
the images.

in your web.config:

<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]"
defaultValue="null"
/>
<add name="PictureType" type="string" />
</properties>
</profile>

your upload page could be like this:

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />

with this in the code behind (C#):

protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile file = FileUpload1.PostedFile;

byte[] data = new byte[file.ContentLength];

file.InputStream.Read(data, 0, file.ContentLength);

Profile.Picture = data;
Profile.PictureType = file.ContentType;
}

your "getImage.aspx" page like this (C#):

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}

and your page that you want to host the image on, like this:

<img src="getImage.aspx" />

HTH

Neil


Jeff wrote:
Hey

(and thank you for reading my post)

In visual web developer 2005 express edition I've created a simple
website
project..

At this website I want users who register to be able to upload a
picture
of
themselves to their profile... I admit that I'm a newbie... but
this
is
how
I understand this:

I create a new section in web.config contain this info
<profile defaultProvider="AspNetSqlProfileProvider">
<properties>
<add name="Name" />
<add name="Picture" type="System.Web.UI.WebControls.Image" />
</properties>
</profile>

Then in the code I can write something like this:

Profile.Picture = <a picture>;

And then during execution of this code the picture is automatically
saved
in
the express database visual web developer 2005 express edition
created
in
this project folder. (the .NET framework creates the new column in
the
user
profile and do all functionality for saving & loading the image
from
the
db)

Is it how it works???

Hmm it can't be correct, because even now I can create new users to
my
website, name & password being used by the login control in my
website...
but all the data my web.config file has is this:
<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/></system.web>
</configuration>
There are no settings here that hold the username and password.....
so
clearly what I suggest above must be wrong!

Please guide me on the right track here, give me some clue I could
look
after... a link explaining this would be great (I've been google
already,
but I think I'm searching with the wrong keywords)

Please, I'm stucked in this, so some suggestions would be greatly
appreaciated!

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,068
Latest member
MakersCBDIngredients

Latest Threads

Top