bdoron פורסם 2014 ביוני 30 Share פורסם 2014 ביוני 30 קראתי איך מעבירים מידע בין דפי asp.net ועשיתי ניסוי, יצרתי אובייקט בשם user שמכיל בפנים כל מיני שדות מסוג stringלאחר מכן בדף הsource רשמתי את הפרופרטי הבא: public User CurrentUser { get { return u; } }ובדף המטרה ( הדף שברגע הresponse אני רוצה לעבור אליו) הבנתי שאני צריך להוסיף בדף הaspx שורת קוד הזאת :<%@ PreviousPageType VirtualPath="~/home.aspx" %> ובנוסף בדף הcs של אותו דף מטרה הוספתי את הקוד הבא: User s; protected void Page_Load(object sender, EventArgs e) { s = new User(); s = PreviousPage.CurrentUser; Label1.Text = s.Country; }השגיאה שאני מקבל היא :[h=2]Object reference not set to an instance of an object.[/h]Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: [TABLE=width: 100%][TR][TD]Line 19: {Line 20: s = new User();Line 21: s = PreviousPage.CurrentUser;Line 22: Label1.Text = s.Country;Line 23: }[/TD][/TR][/TABLE]Source File: c:\inetpub\wwwroot\DatingGame\PicturesAlbom.aspx.cs Line: 21 Stack Trace: [TABLE=width: 100%][TR][TD][NullReferenceException: Object reference not set to an instance of an object.] PicturesAlbom.setUser() in c:\inetpub\wwwroot\DatingGame\PicturesAlbom.aspx.cs:21 PicturesAlbom.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\DatingGame\PicturesAlbom.aspx.cs:14 System.Web.UI.Control.LoadRecursive() +70 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3177[/TD][/TR][/TABLE] קישור לתוכן שתף באתרים אחרים More sharing options...
Recommended Posts
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.