Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > .NET Framework > Forum > (C#) MessageBox.Show ใช้กับ Web form ไม่ได้หรอครับ ? --ต้อง using อะไรก่อนครับ



 

(C#) MessageBox.Show ใช้กับ Web form ไม่ได้หรอครับ ? --ต้อง using อะไรก่อนครับ

 



Topic : 050611



โพสกระทู้ ( 47 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์




พิมพ์ MessageBox ก็ไม่มี auto complete ขึ้น แปลว่ามันใช้ไม่ได้หรือ ต้อง using อะไรก่อนครับ



Tag : .NET, Web (ASP.NET), C#







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-10-22 11:51:04 By : zixsenz View : 11073 Reply : 14
 

 

No. 1



โพสกระทู้ ( 3,748 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์
Facebook

มันมีนะครับ แต่ไม่รู้ว่ามันแล้วแต่เหตุการณ์ที่จะใช้หรือป่าว บางทีพิมพ์ msgbox.show ก็ขึ้น บางครั้งก็ต้องพิมพ์ messagebox.show






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 11:54:40 By : Dragons_first
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Confirm (VB.NET)
        If MessageBox.Show("Are you sure to exit?", "Confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
            Application.Exit()
        End If


Message Box (VB.NET)
MessageBox.Show("Please input (Name)")

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 12:01:07 By : webmaster
 

 

No. 3



โพสกระทู้ ( 47 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ตอบความคิดเห็นที่ : 2 เขียนโดย : webmaster เมื่อวันที่ 2010-10-22 12:01:07
รายละเอียดของการตอบ ::
.ของผม C# อ่ะครับ

แล้วก็ มันไม่ขึ้นเลยครับ ทั้ง MessageBox ทั้ง MsgBox -*-

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 12:23:26 By : zixsenz
 


 

No. 4

Guest


MessageBox.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections;
using System.Text;

/// <summary>
/// Summary description for MessageBox
/// </summary>
public class MessageBox
{
    private static Hashtable m_executingPages = new Hashtable();
    
    public MessageBox()
	{
		//
		// TODO: Add constructor logic here
		//
	}
 
    public static void Show(string sMessage)
    {
        // If this is the first time a page has called this method then
        if(!m_executingPages.Contains(HttpContext.Current.Handler))
        {
            // Attempt to cast HttpHandler as a Page.
            Page executingPage = HttpContext.Current.Handler as Page;

            if(executingPage != null)
            {
                // Create a Queue to hold one or more messages.
                Queue messageQueue = new Queue();
                // Add our message to the Queue
                messageQueue.Enqueue(sMessage);
                // Add our message queue to the hash table. Use our page reference
                // (IHttpHandler) as the key.
                m_executingPages.Add(HttpContext.Current.Handler, messageQueue);
                // Wire up Unload event so that we can inject
                // some JavaScript for the alerts.
                executingPage.Unload += new EventHandler(ExecutingPage_Unload);
            }  
        }
        else
        {
            // If were here then the method has allready been
            // called from the executing Page.
            // We have allready created a message queue and stored a
            // reference to it in our hastable.
            Queue queue = (Queue) m_executingPages[HttpContext.Current.Handler];
            // Add our message to the Queue
            queue.Enqueue(sMessage);
        }
    }

    // Our page has finished rendering so lets output the
    // JavaScript to produce the alert's
    private static void ExecutingPage_Unload(object sender, EventArgs e)
    {
        // Get our message queue from the hashtable
        Queue queue = (Queue) m_executingPages[HttpContext.Current.Handler];

        if(queue != null)
        {
            StringBuilder sb = new StringBuilder();
            // How many messages have been registered?
            int iMsgCount = queue.Count;
            // Use StringBuilder to build up our client slide JavaScript.
            sb.Append("<script language='javascript'>");
            // Loop round registered messages
            string sMsg;

            while(iMsgCount-- > 0)
            {
                sMsg = (string) queue.Dequeue();
                sMsg = sMsg.Replace( "\n", "\\n" );
                sMsg = sMsg.Replace( "\"", "'" );
                sb.Append( @"alert( """ + sMsg + @""" );" );
            }
            // Close our JS
            sb.Append(@"</script>");
            // Were done, so remove our page reference from the hashtable
            m_executingPages.Remove(HttpContext.Current.Handler);
            // Write the JavaScript to the end of the response stream.
            HttpContext.Current.Response.Write(sb.ToString());
        }
    }
}


คลิกขวาที่ folder app_code แล้ว add new item เป็น class แล้วก็อปด้านบนไปใส่

ไปปลูกผักต่อแล้ว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 12:50:07 By : ตังค์แมน
 


 

No. 5



โพสกระทู้ ( 47 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


โห

สรุปคือแค่ MessageBox นี่ C# ต้องเขียน class ขึ้นมาเองเลยหรอครับ ><
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 13:17:31 By : zixsenz
 


 

No. 6



โพสกระทู้ ( 1,035 )
บทความ ( 0 )



สถานะออฟไลน์


จริงแล้วใช้ MsgBox.Show ก็ได้เหมือนกันครับ แต่ที่ไม่ขึ้นี้ผมว่า คุณเขียนยังไงถึงไม่ขึ้นมากกว่า
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 13:24:53 By : kanchen
 


 

No. 8



โพสกระทู้ ( 47 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ตอบความคิดเห็นที่ : 6 เขียนโดย : kanchen เมื่อวันที่ 2010-10-22 13:24:53
รายละเอียดของการตอบ ::
จริงแล้วใช้ MsgBox.Show ก็ได้เหมือนกันครับ แต่ที่ไม่ขึ้นี้ผมว่า คุณเขียนยังไงถึงไม่ขึ้นมากกว่า


ไม่ได้อ่ะครับ

เท่าที่หาๆดู Code C# ที่อยู่ดีๆจะมาใช้ MsgBox เลยไม่ได้ครับ ต้องเขียนฟังก์ชันขึ้นมาเอง แล้วถึงเรียกใช้

ไม่ก็ใช้ writeline javascript alert เอา
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 15:14:49 By : zixsenz
 


 

No. 9



โพสกระทู้ ( 183 )
บทความ ( 0 )



สถานะออฟไลน์


ถูกครับ VS(C#) บางตัวจะไม่มี MsgBox ให้เรียกใช้งาน

ลองค้นหากระทู้เก่าๆดูครับ อาจมีคำตอบให้คุณได้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 16:45:49 By : 3rds
 


 

No. 10

Guest


ใช้ javascript ดีกว่านะครับ
Response.Write("<script type="text/javascript">alert('test');</script>");
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 18:53:56 By : เราเอง
 


 

No. 11



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ตอบความคิดเห็นที่ : 5 เขียนโดย : zixsenz เมื่อวันที่ 2010-10-22 13:17:31
รายละเอียดของการตอบ ::
เขียนด้วย javascript ก็ได้ แต่ตรงไป regidter start up script อะไรวุ่นวายอีก

ทำเป็น class ไว้แหละ เวลาเวลาใช้ก็แค่ MessageBox.Show("xxx"); จะใช้ตรงไหนก็ได้

แล้วตอนใช้ก็ให้ความรู้สึกเหมือนเขียน win app ด้วย



ประวัติการแก้ไข
2010-10-22 19:25:57
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 19:25:08 By : tungman
 


 

No. 12



โพสกระทู้ ( 24 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook

เขียน MSG บน webform ไม่เหมือนเขียนบน windown form น่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-30 11:37:45 By : Noomyontrakit
 


 

No. 13

Guest


ตอบความคิดเห็นที่ : 4 เขียนโดย : ตังค์แมน เมื่อวันที่ 2010-10-22 12:50:07
รายละเอียดของการตอบ ::
ผมทำตามนี้แล้วก็สามารถใช้ คำสั่งmessageboxได้ แต่ทำได้แค่ messagebox.Show("text"); อะคับ


ยังไม่สามารถใช้ คำสั่ง If MessageBox.Show("Are you sure to exit?", "Confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
Application.Exit() ได้เลย ไม่ทราบว่าทำอย่างไรดีครับ มือใหม่ช่วยดีครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-11-13 22:07:33 By : mrkrittin
 


 

No. 14

Guest


Code (C#)
lberror.Text = "กรุณาตรวจสอบข้อมูล";
                    lberror.Visible = true;

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-18 16:42:45 By : a
 


 

No. 15

Guest


ฮ่วย มันจะไปเหมือน msg ของ win form ได้ไงเล่า

class นี้ทำให้สามารถใช้ javascript alert message แบบง่ายๆ โดยไม่ต้องไปเขียน javascipt ยาวๆ

โดยให้วิธีการใช้งานคล้ายๆ ของ win form แค่นั้นแหละ โดยความสามารถก็แค่ alert message

เช่น

Code (C#)
protected void Button1_Click(object sender, EventArgs e)
{
   MessageBox.Show("แสดง alert");
}



ไม่ถึงกับเหมือน messagebox จริงๆ หรอก ถ้าจะให้ได้แบบนั้นต้องใช้ popup model แล้ว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-06 14:16:19 By : ห้ามตอบเกินวันละ 2 กระทู้
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : (C#) MessageBox.Show ใช้กับ Web form ไม่ได้หรอครับ ? --ต้อง using อะไรก่อนครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่