473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

saving picture to a user profile!

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
Jun 28 '06 #1
6 8087
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


Jun 29 '06 #2
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

<ne**********@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
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

Jun 29 '06 #3
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

<ne**********@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
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


Jun 29 '06 #4
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?
<ne**********@gmail.com> wrote in message
news:11**********************@x69g2000cwx.googlegr oups.com...
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

<ne**********@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
> 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
>

Jun 29 '06 #5
why are you doing it that way? thx
Jeff wrote:
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?
<ne**********@gmail.com> wrote in message
news:11**********************@x69g2000cwx.googlegr oups.com...
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

<ne**********@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
> 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
>


Jun 30 '06 #6
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!


<ne**********@gmail.com> wrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
why are you doing it that way? thx
Jeff wrote:
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?
<ne**********@gmail.com> wrote in message
news:11**********************@x69g2000cwx.googlegr oups.com...
> 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
>>
>>
>>
>>
>>
>> <ne**********@gmail.com> wrote in message
>> news:11**********************@p79g2000cwp.googlegr oups.com...
>> > 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
>> >
>

Jun 30 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Anon | last post by:
Hello All! I was wondering how I can go about saving the last string entered into a textbox. I would like to save username or pwd info in textboxes in my forms so that users don't have to...
1
by: sonic | last post by:
so, profile provider is a way to save application preferenes for each user. the profile can be replaced to provide a different persistance layer, and/or schema, but what about tweaking it to work...
4
by: public2 | last post by:
Hi. This is my first post, and is about an assignment I've at my college. An overall description: We have to make a function, with one argument, the URL. then we have to search the HTML code...
4
by: Ismail | last post by:
Hello, I am using asp.net20 membership. I have some properties in web.config <properties> <add name="FirstName" type="System.String" allowAnonymous="true"/> <add name="LastName"...
3
by: daokfella | last post by:
I want to be able to store profile information for a user when they sign up for an account...but BEFORE they can log in. Can this be done using any of the built-in profile methods? Here's my...
9
by: =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post by:
I have an app that prints entry tickets. If the printer driver is not set up exactly to detect the black mark on the back of the ticket, the tickets do not print correctly. Because of this, all...
0
by: akle | last post by:
hello... Let me explain my problem by giving an example. I have lots of users and their profiles having personal picture in it. If someone makes a search lets say s/he is searching for...
4
by: Scott M. | last post by:
When profile data is stored in ASP .NET, where is the user data persisted? For how long is it persisted: is it session persisted or permanent (like a cookie)?
5
by: zamuel | last post by:
Hey everyone. I have a strange problem with PHP site. This only happens in IE 6. So, when user logs in there is a placeholder for user's own picture. Also there is a form where this picture can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.