נגיד עכשיו יש לי פקד עצמי המטרה שלנו לניהול.
במצב רגיל משתמש רגיל הוא מציג טקטס ו HTML.
במצב ניהול הוא מציג את העורך.
מקווה שעד לכאן ברור.עכשיו נגיד אני שם 2 או יותר פקדים מהסוג הזה באותו דף הקריאה לפקודה אצלו מעוררת את המתודה של ה page_load מה שגורם לשינוי בכל הפקדים על הדף.
עכשיו הקטע הוא שהנתונים שלי "נמחקים" לי בכל פעם שאני מריץ פקודה על הפקד כאילו הוא מאפס את עצמו , ככה שהדרך היחידה שאני מכיר היא להשים את המשתנים בגלובל אבל זה הכי לא יעיל בעולם! או במקביל להשתמש בקוקיס עבור כל פקד , גם משהו שאני לא רוצה.
מה שאני מנסה להגיד אם יש איזושהי דרך לשמר את הנתונים של הפקדים שהם לא ימחקו אחרי כל הרצת פקודה.
ניסתי AJAX אבל בכל מקרה זה מעדכן לי את הדפים משום מה הוא לא מקבל את הפקודות של ה AJAX בפקד פה.. מוזר.
מה שאני עשיתי זה להשתמש בפקדים מוסתרים כדי לשמור את הנתונים כי רק ככה הוא שומר לי את הנתונים משום מה הוא מתאפס לי על הקוד.
אני יוסיף פה את הקוד למקרה שפיספסתי משהו או שאני לא רואה משהו ואתה יכול לראות ...
Partial Class Admin_controls_contant Inherits System.Web.UI.UserControl Private _mode As Integer Private _Contant As Integer Public htmlout As String Dim x As New main.Content Public Property modex() As Integer Get Return _mode End Get Set(ByVal value As Integer) _mode = value End Set End Property Public Property con() As Integer Get Return _Contant End Get Set(ByVal value As Integer) TextBox1.Text = _Contant _Contant = value End Set End Property Public Function SetCon(ByVal ID As Integer) As Boolean TextBox1.Text = ID _Contant = ID Return True End Function Protected Sub Page_CommitTransaction(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.CommitTransaction MsgBox("xxx") End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Button1.Visible = True FCKeditor1.BasePath = "~/fckeditor/" FCKeditor1.ToolbarSet = "Scms" If Not IsPostBack Then If _mode = 0 Then Me.FCKeditor1.Value = x.GetCon(_Contant) TextBox1.Text = _Contant Else Me.FCKeditor1.Visible = False Me.htmlout = x.GetCon(_Contant) TextBox1.Text = _Contant End If Else _Contant = Int(TextBox1.Text) If FCKeditor1.Visible = False Then Me.htmlout = x.GetCon(_Contant) End If End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click FCKeditor1.BasePath = "~/fckeditor/" FCKeditor1.Visible = True FCKeditor1.Value = x.GetCon(_Contant) htmlout = "" _mode = 0 Button1.Visible = False Button2.Visible = True Button3.Visible = True Button4.Visible = True 'End If End Sub Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click FCKeditor1.Visible = False htmlout = x.GetCon(_Contant) _mode = 1 Button1.Visible = True Button2.Visible = False Button3.Visible = False Button4.Visible = False End Sub Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click htmlout = "<table border='1' ><tr><td>" htmlout += FCKeditor1.Value htmlout += "</tr><td></table>" FCKeditor1.Visible = True End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click If x.UpdateCon(_Contant, FCKeditor1.Value) Then Label1.Text = "עריכת התוכן סוימה בהצלחה." Label1.ForeColor = Drawing.Color.Green FCKeditor1.Visible = False htmlout = x.GetCon(_Contant) _mode = 1 Button1.Visible = True Button2.Visible = False Button3.Visible = False Button4.Visible = False Me.Page_Load(sender, e) Else Label1.Text = "אירעה שגיאה בעריכת התוכן" Label1.ForeColor = Drawing.Color.Red End If End Sub End Class
|
ואם כבר על הדרך יש לי עוד שאלה...( בחור סקרן
)
נגיד יש לי עכשיו GRIDVIEW ועשיתי לאחד מן הערכים שיהיה בטמפלט עכשיו אני רוצה להכניס לתוך ה DB בבינדינג ערך קבוע דרך הפקד.
שהוא PROPERTY בקוד.
ניסתי כמעט כל דבר ואני לא מצליח , הקוד לא רוצה לצאת מהתחום של הגריד והוא נותן לי רק לעשות לו ביינדינג.
עכשיו ניסתי לעשות לו משהו כזה..
'כאן זה הפרופרטי כפובליק <%# MenuGroup %>
|
והוא נותן לי בתצוגה את החיבור שלו והכל טוב ויפה אבל הוא לא מכניס לי אותו לדאטהבייס
יש עוד דבר אחד שלא ניסתי ואני מאמין שהוא יעבוד אבל לפני שחשבתי עליו כבר עשיתי הכל ידני ככה שאין לי כוח לעשות את זה עוד פעם , מה שחשבתי הוא ללכת ל דאטהקונקטור ולבנות שם פרמטר של פקד ומשם לעשות לו בינדינג
תגיד לי אם זה אפשרי אם אתה יודע שלפעם הבאה אני ישתמש בזה.
תודה רבה על התגובה ועל התמיכה.
ליאור