 |
|
ขอถามหน่อยครับ เรื่องการเรียก Method มาใช้ในหน้า view.aspx ยังไงครับ |
|
 |
|
|
 |
 |
|
กระทู้นี้ได้แล้วหรือยังครับ 
|
 |
 |
 |
 |
Date :
2015-02-21 09:01:29 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นั่นสิครับ จริงๆการดึงค่าข้อมูลมาเสนอหน้าใน page นี่
มัน code-less เลยก็ได้นะ นั่ง click สามคราก็ได้ ดาต้ามาให้เชยชมละ
|
 |
 |
 |
 |
Date :
2015-02-22 21:38:16 |
By :
BIG BAD DOG |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ๋อได้แล้วครับ ผมประกาศตัวแปร arrnew ไว้ในหน้า view.cs แล้วเอาไปใช้ในหน้า view.aspx ได้เลย
Code (C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Project
{
public partial class view: System.Web.UI.Page
{
public List<Dictionary<string, string>> arrnew;
public List<Dictionary<string, string>> arrpopular;
public List<Dictionary<string, string>> arrall;
public Dictionary<string, string> arr_favorite;
protected void Page_Load(object sender, EventArgs e)
{
cIndex index = new cIndex();
arrnew = index.DaraNew();
arrpopular = index.DaraPopular();
arrall = index.DaraAll();
arr_favorite = Session["arr_favorite"] as Dictionary<string, string>;
}
}
}
ขอบคุณครับ
|
ประวัติการแก้ไข 2015-02-26 16:57:59 2015-02-26 16:58:03 2015-02-26 16:58:57 2015-02-26 16:59:11
 |
 |
 |
 |
Date :
2015-02-26 16:57:37 |
By :
เด็กโง่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จุดอ่อน(ด้อย) ของ Session["arr_favorite"]
For i As myVariable = 0 TO 100
...
Next
แค่นี้คุณก็จำไม่ได้แล้วว่า arr_favorite เขียนอย่างไร?
|
 |
 |
 |
 |
Date :
2015-02-26 17:02:56 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Session["arr_favorite"] == สระอู
For x As Var In Session
Session["arr_favorite_1234"] == สระอู
//จุดบอดสนิท
Next
Console.WriteLine(Session["arr_favorite"]) --> Nothing
|
 |
 |
 |
 |
Date :
2015-02-26 17:07:34 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 5 เขียนโดย : เด็กโง่ เมื่อวันที่ 2015-02-26 17:07:18
ลองสังเกตุดูครับ
Code (C#)
Session("A") = value;
Session("B") = value;
Session("C") = value;
...
...
...
เยอะมากฯ
Session("name") = value;
ถ้าระบบงานใหญ่ฯ และคุณจำเป็นต้องเขียน คนเดียว (ใช้คนน้อยคน)
มันเปลือพลังงานสมอง มหาศาล ครับ โอกาสผิดพลาดสูงมากฯ
ทางแก้ไขที่ดีกว่าเดิมแน่นอนนั่นคือ
คุณจำเป็นต้องเขียน Class ขึ้นมา 1 ตัวเพื่อจัดการกับ Seesion จะทำอย่างไรก็แล้วแต่ความชอบ
...
...
ปล. ยังนึกไม่ออก
|
 |
 |
 |
 |
Date :
2015-02-27 10:05:27 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|