PDA

View Full Version : سوال: error در طراحی پروفایل



htmbarnamenevisl
دوشنبه 25 آذر 1387, 19:00 عصر
سلام
من برای طراحی وب سایتم( به اجبار استادم) دارم از member ship استفاده می کنم
یه صفحه برای پروفایل کاربر طراحی کردم به اسم profile اما با این error مواجه شدم
این error به خاطر چیه ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟




Error 1 'Profile': member names cannot be the same as their enclosing type c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET Files\d\215de08f\633bc6ec\App_Web_yqwlqd3i.4.cs 254


روی این error که دابل کلیک میکنم کنار این تابع علامت دار شده







protected ProfileCommon Profile {
get {
return ((ProfileCommon)(this.Context.Profile));
}


}

htmbarnamenevisl
سه شنبه 26 آذر 1387, 15:43 عصر
هیچ کس نمی تونه به من کمک کنه
کمک کمک کمک کمک؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟؟؟!!!!!!!!!!!!!!!!!!!!!!!!!!!

Saber_Fatholahi
شنبه 30 آذر 1387, 11:41 صبح
دوست من آیا اصلا فیلد هاتو برای پروفایل تعریف کردی اگه امکان داره کد خودتو بذار که بتونم کمکت کنم منم توی پروژم از پروفایل استفاده کردم ببین به کارت میاد

r_mehrizi
شنبه 30 آذر 1387, 12:29 عصر
دوست من آیا اصلا فیلد هاتو برای پروفایل تعریف کردی اگه امکان داره کد خودتو بذار که بتونم کمکت کنم منم توی پروژم از پروفایل استفاده کردم ببین به کارت میاد

شما از قابليت خاصي براي پروفايل استفاده مي كنيد ميشه بيشتر توضيح بديد

Saber_Fatholahi
شنبه 30 آذر 1387, 12:47 عصر
خوب دوست من برای استفاده از پروفایل ابتدا باید فیلد هاتو توی فایل web.config تعریف کنی بعدم از توی صفحات سایتت برای دسترسی به گزینه های پروفایل Profile.yourfiled استفاده کنی که هم خواندنی هم نوشتنی هست اگرم خواستی تغییراتت ذخیره بشه از Profile.Save() استفاده می کنی در صورتی هم که بخوای پروفایل کاربرای دیگرو بدست بیاری از تعریف ProfileCommon استفاده می کنی من توی پروژم که توی این سایت گذاشتم کامل با پروفایل کار کردم در صورت اطلاعات بیشتر هم می تونی یه سر به این لینکها بزنی
لینک 1
(http://msdn.microsoft.com/en-us/library/ms379605.aspx)
لینک (http://flimflan.com/blog/ProfileView.aspx)2

موفق باشی

htmbarnamenevisl
یک شنبه 01 دی 1387, 04:02 صبح
سلام
من تو پروژم از profile استفاده کردم
از دستورای زیر برای ذخیره پروفایل هر کس و نقش دادن بهش استفاده میکنم
اما چیزی در بانک ذخیره نمی شه


string username = CU.UserName;
try
{
// Create an empty Profile for the newly created user
ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CU.UserName, true);
p.FirstName = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("FristName")).Text;
// Populate some Profile properties off of the create user wizard
p.LastName = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("LastName")).Text;
p.Commerce.Address = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("Adress")).Text;
p.Commerce.City = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("City")).Text;
p.Commerce.Country = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("Country")).Text;
p.Forum.BirthDate = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("BirthDate")).Text;
p.Forum.Email = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("Email")).Text;
p.Commerce.PostalCode = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("PostalCode")).Text;
p.Commerce.Province = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("Province")).Text;
p.Commerce.PhoneNo = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("PhoneNo")).Text;
// Save the profile - must be done since we explicitly created this profile instance
p.Save();
Roles.AddUserToRole(username, "User");
}
catch
{
}// Add user to role





تو صفحه پروفایل هم اینجوری فراخوانی کردم

if (!Page.IsPostBack)
{
FirstName.Text = Profile.FirstName;
LastName.Text = Profile.LastName;
UserName.Text = Profile.UserName;
Email.Text = Membership.GetUser().Email;
BirthDate.Text = Profile.Forum.BirthDate;
Occupation.Text = Profile.Forum.Occupation;
WebSite.Text = Profile.Forum.WebSite;

Address.Text = Profile.Commerce.Address;
Country.Text = Profile.Commerce.Country;
City.Text = Profile.Commerce.City;
Province.Text = Profile.Commerce.Province;
Postal.Text = Profile.Commerce.PostalCode;
PhoneNo.Text = Profile.Commerce.PhoneNo;
FaxNo.Text = Profile.Commerce.FaxNo;
}
}
protected void BtnSave_Click(object sender, EventArgs e)
{
try
{
Profile.FirstName = FirstName.Text;
Profile.LastName = LastName.Text;

Profile.Forum.BirthDate = BirthDate.Text;
Profile.Forum.Occupation = Occupation.Text;
Profile.Forum.WebSite = WebSite.Text;

Profile.Commerce.Address = Address.Text;
Profile.Commerce.Country = Country.Text;
Profile.Commerce.City = City.Text;
Profile.Commerce.Province = Province.Text;
Profile.Commerce.PostalCode = Postal.Text;
Profile.Commerce.PhoneNo = PhoneNo.Text;
Profile.Commerce.FaxNo = FaxNo.Text;
Profile.Save();
SaveSuccess.Text = "ꬦ­ں¢ ¬êں ں êيهçی¢ ¨¦ی©ى ¬§.";
SaveSuccess.Visible = true;
}
catch
{
SaveSuccess.Text = "ꬦ­ں¢ ¬êں ى §éیé ê¬کéں¢ی ¨¦ی©ى 묧، §ي ں©ى «می کëی§.";
SaveSuccess.Visible = true;
}


اینا رو داخل وب کانفیگ نوشتم


<anonymousIdentification enabled="true"/>
<profile enabled="true">
<properties>
<group name="Commerce">
<add name="Address"/>
<add name="Province"/>
<add name="City"/>
<add name="Country"/>
<add name="PostalCode"/>
<add name="PhoneNo"/>
<add name="FaxNo"/>
</group>
<add name="FirstName"/>
<add name="MiddleName"/>
<add name="LastName"/>
<group name="Forum">

<add name="BirthDate"/>

<add name="Occupation"/>
<add name="WebSite"/>
<add name="Email"/>
<add name="PostCount" type="System.Int32"/>
</group>
</properties>
</profile>


من چی رو فراموش کردم
راستی من کانکشن data base خود asp رو تغییر دادم


<appSettings>
<add key="ShopConnection" value="Data Source=.;Initial Catalog=shop;Integrated Security=True"/>
</appSettings>


<connectionStrings>
<clear />
<add name="ShopConnection" connectionString="Data Source=.;Initial Catalog=shop;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

اشکال کار من کجاست

Saber_Fatholahi
سه شنبه 03 دی 1387, 13:43 عصر
سلام
من تو پروژم از profile استفاده کردم
از دستورای زیر برای ذخیره پروفایل هر کس و نقش دادن بهش استفاده میکنم
اما چیزی در بانک ذخیره نمی شه


string username = CU.UserName;
try
{
// Create an empty Profile for the newly created user
ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CU.UserName, true);
p.FirstName = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("FristName")).Text;
// Populate some Profile properties off of the create user wizard
p.LastName = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("LastName")).Text;
p.Commerce.Address = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("Adress")).Text;
p.Commerce.City = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("City")).Text;
p.Commerce.Country = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("Country")).Text;
p.Forum.BirthDate = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("BirthDate")).Text;
p.Forum.Email = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("Email")).Text;
p.Commerce.PostalCode = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("PostalCode")).Text;
p.Commerce.Province = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("Province")).Text;
p.Commerce.PhoneNo = ((TextBox)CU.CreateUserStep.ContentTemplateContain er.FindControl("PhoneNo")).Text;
// Save the profile - must be done since we explicitly created this profile instance
p.Save();
Roles.AddUserToRole(username, "User");
}
catch
{
}// Add user to role




تو صفحه پروفایل هم اینجوری فراخوانی کردم

if (!Page.IsPostBack)
{
FirstName.Text = Profile.FirstName;
LastName.Text = Profile.LastName;
UserName.Text = Profile.UserName;
Email.Text = Membership.GetUser().Email;
BirthDate.Text = Profile.Forum.BirthDate;
Occupation.Text = Profile.Forum.Occupation;
WebSite.Text = Profile.Forum.WebSite;

Address.Text = Profile.Commerce.Address;
Country.Text = Profile.Commerce.Country;
City.Text = Profile.Commerce.City;
Province.Text = Profile.Commerce.Province;
Postal.Text = Profile.Commerce.PostalCode;
PhoneNo.Text = Profile.Commerce.PhoneNo;
FaxNo.Text = Profile.Commerce.FaxNo;
}
}
protected void BtnSave_Click(object sender, EventArgs e)
{
try
{
Profile.FirstName = FirstName.Text;
Profile.LastName = LastName.Text;

Profile.Forum.BirthDate = BirthDate.Text;
Profile.Forum.Occupation = Occupation.Text;
Profile.Forum.WebSite = WebSite.Text;

Profile.Commerce.Address = Address.Text;
Profile.Commerce.Country = Country.Text;
Profile.Commerce.City = City.Text;
Profile.Commerce.Province = Province.Text;
Profile.Commerce.PostalCode = Postal.Text;
Profile.Commerce.PhoneNo = PhoneNo.Text;
Profile.Commerce.FaxNo = FaxNo.Text;
Profile.Save();
SaveSuccess.Text = "ꬦ­ں¢ ¬êں ں êيهçی¢ ¨¦ی©ى ¬§.";
SaveSuccess.Visible = true;
}
catch
{
SaveSuccess.Text = "ꬦ­ں¢ ¬êں ى §éیé ê¬کéں¢ی ¨¦ی©ى 묧، §ي ں©ى «می کëی§.";
SaveSuccess.Visible = true;
}
اینا رو داخل وب کانفیگ نوشتم


<anonymousIdentification enabled="true"/>
<profile enabled="true">
<properties>
<group name="Commerce">
<add name="Address"/>
<add name="Province"/>
<add name="City"/>
<add name="Country"/>
<add name="PostalCode"/>
<add name="PhoneNo"/>
<add name="FaxNo"/>
</group>
<add name="FirstName"/>
<add name="MiddleName"/>
<add name="LastName"/>
<group name="Forum">

<add name="BirthDate"/>

<add name="Occupation"/>
<add name="WebSite"/>
<add name="Email"/>
<add name="PostCount" type="System.Int32"/>
</group>
</properties>
</profile>
من چی رو فراموش کردم
راستی من کانکشن data base خود asp رو تغییر دادم


<appSettings>
<add key="ShopConnection" value="Data Source=.;Initial Catalog=shop;Integrated Security=True"/>
</appSettings>


<connectionStrings>
<clear />
<add name="ShopConnection" connectionString="Data Source=.;Initial Catalog=shop;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
اشکال کار من کجاست

دوست من مرا حل کارت درسته فقط باید توی تنظیمات پروفایل توی وب کانفیگ نام کانکشن خوتو بنویسی مثل زیر

<profile defaultProvider="SqlProvider">
<providers>
<clear/>
<add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="YourconectionName"/>
</providers>
<properties>
<add name="BirthYear" type="String"/>
<add name="Sokonat" type="String"/>
<add name="Website" type="String"/>
<add name="ICQ" type="string"/>
<add name="HotmailID" type="String"/>
<add name="SkypeName" type="String"/>
<add name="AIM" type="String"/>
<add name="YahooID" type="String"/>
<add name="Signature" type="String"/>
<add name="MSN" type="String"/>
</properties>
</profile>