.NET Logo
Welcome Guest Search | Active Topics | Members | Log In | Register

การใช้งาน DropDownExtender และการใส่เงาให้กับ DropDownList Options · View
paedotnet
Posted: Thursday, October 02, 2008 10:41:29 PM

Rank: มือเทพ
Groups: Member

Joined: 12/6/2007
Posts: 345
Location: bkk

การใช้งาน DropDownExtender
ในการใช้งาน DropDownExtender ได้จะต้องติดตั้ง AjaxControlToolKit ก่อน
พอติดตั่งแล้วก็จะมี tool ที่ชื่อ DropDownExtender ดังรูป


ในการใช้งานนี้ เราไม่สามารถที่จะใช้ งาน DropDownExtender ได้อย่างเดี่ยวๆแต่ต้องใช้งานคู่กับ
DropDownList
1. ให้ลาก ScriptManager มาวางในหน้า web form
2.  จากนั้นลาก DropDownList มาวางใน หน้า web form ดังรูป


3. จากนั้นลาก DropDownExtender มาวางใน DropDownList  ดังรูป


4. ให้คลิกที่ Enable AutoPostBack แล้วถ้าต้องการใส่เงาให้กับ DropDownList ก็คลิกที่ Add Extender...
    พอคลิกแล้วจะมีหน้าต่าง Extender Wizard ขึ้นมา แล้วให้เลือก DropShadowExtender ดังรูป 

  แล้วกด ok
5. จากนั้นคลิกตรงลูกศรด้านบนขวาที่ DropDownlist แล้วเลือก Edit Item จากนั้นจะมีหน้าต่าง ListItem Collection Editor
    ขึ้นมาให้คลิกที่ Add เพื่อเพิ่ม item ต่างลงไปดังรูป 

 

ที่ต้องเพิ่ม item ก็เพราะว่า ให้ผู้ใช้เลือก item ที่ต้องการแล้วก็จะ แสดงออกมาทางหน้าจอ
6. จากนั้นดับเบิลคลิกที่ DropDownList แล้วเขียนโค้ดดังนี้ 
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Response.Write(DropDownList1.SelectedItem.Text);
    }

7. จากนั้นทดสอบดู สังเกตว่า dropdownlist จะมีเงาเกิดขึ้นดังรูป 

 

เมื่อเลือกที่ item ก็จะแสดงชื่อ item นั้นออกมา ดังรูป



[With great power comes great responsibility]
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.


Sponsored by