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

รบกวนหน่อยครับเรื่องการทำ popup ครับ Options · View
zymethseven
Posted: Tuesday, May 20, 2008 5:23:53 PM
Rank: มือฝึกหัด
Groups: Member

Joined: 3/12/2008
Posts: 4
Location: Bangkok

 ใครรู้ ขอรบกวน หน่อยครับวิธีการทำ popup ให้กับเว็ปนะครับ ขอบคุณมากครับ อยากรู้จริงๆครับ เพราะต้องเอาไปทำงานส่งอาจารย์นะครับ

 

ขอบคุณมากครับ

paedotnet
Posted: Tuesday, May 20, 2008 7:33:17 PM

Rank: มือเทพ
Groups: Member

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

สำหรับการแสดง popup นะครับ จะให้แสดง popup แบบใหนเหรอครับ (javascript / MessageBox )
ถ้าเป็น messagebox ก็ให้ไปที่ชื่อโปรเจคคลิกขวาเลือก  Add Reference ... แล้วเลือก แถบ ที่ชื่อว่า .NET แล้วเลือก  System.Windows.Forms  จากนั้นมาในหน้า webform.aspx.cs
ให้ใส่ namespace เข้าไปดังนี้

using System.Windows.Forms;
 

จากนั้นจะให้แสดง popup ตอนไหนก็เขียนโค้ด เช่นถ้าคลิกที่ปุ่ม Button แล้วให้แสดง popup ขึ้นมาก็เขียนโค้ดดังนี้

  protected void Button1_Click(object sender, EventArgs e) //ต้องดับเบิลคลิกที่ปุ่มก่อน
        {
            MessageBox.Show("Hello", "Welcome", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
        }


 

หรือถ้าต้องการแสดง popup โดยใช้ javascript ก็ต้องถามก่อนนะครับว่าจะแสดง popup แบบไหน เช่นแบบ ให้ใส่ข้อมูลได้ หรือแบบ  แสดงเพื่อการยืนยันค่าบางอย่าง

ตัวอย่าง

 

   protected void Page_Load(object sender, EventArgs e)
        {
            Button1.Attributes.Add("onclick", "javascript:if(confirm('Test')==false)return false;");
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
       
        }


 

ในตัวอย่างนี้ พอคลิกที่ปุ่ม Button1 ก็จะมี popup เกิดขึ้นมา

 


*** ยังมีวิธีสร้าง popup หลายแบบนะครับนอกจากที่แสดงตามตัวอย่างที่ยกตัวอย่างมา ขึ้นอยู่กับรูปแบบการใช้งานครับว่าต้องการใช้งานแบบไหน

 



[With great power comes great responsibility]
zymethseven
Posted: Wednesday, May 21, 2008 8:47:57 PM
Rank: มือฝึกหัด
Groups: Member

Joined: 3/12/2008
Posts: 4
Location: Bangkok

ขอบคุณมากๆเลยครับ   แบบทีกดตรงชื่อนั้แล้วมีpopupขึ้นมา เพื่อสามารถที่จะใส่ข้อมูลไปเก็บไว้ได้อะครับ

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