473,241 Members | 1,801 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,241 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 8061
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.