473,597 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Msgbox

31 New Member
I am developing a website that uses ASPX and CS files...

I have three check boxes and a button... if the user presses a button without checking any checkbox then i want to give a warning message to the user "Please select atleast one".

in VB i used to write

MsgBox("Please select atleast one")

but i dont know how i can do it in the web... please help on how to give the messagebox...
Dec 6 '09 #1
3 2502
sanjib65
102 New Member
You can specify that a user must provide information in a specific control on an ASP.NET Web page by adding a RequiredFieldVa lidator control to the page and linking it to the required control.
The steps are:
1) Add a RequiredFieldVa lidator control to the page and set the following properties:

ControlToValida te: The ID of the control for which the user must provide a value.

ErrorMessage, Text, Display: Properties that specify the text and location of the error or errors that will appear if the user skips the control. For details, see :

http://http://msdn.microsoft.com/en-.../1ze30x3t.aspx

Expand|Select|Wrap|Line Numbers
  1. <asp:CheckBox id="SomeThing" runat="server"></asp:CheckBox>
  2. <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
  3.   ControlToValidate="txtLastName"
  4.   ErrorMessage="You have to select a field."
  5.   ForeColor="Red">
  6. </asp:RequiredFieldValidator>
For further reading you can check this link:

http://http://msdn.microsoft.com/en-.../bwd43d0x.aspx
Dec 6 '09 #2
sanjib65
102 New Member
I have forgotten to add one more thing. Besides Framework Validation controls you can Validate Programmaticall y for ASP.NET Server Controls. You can learn about that in:

http://http://msdn.microsoft.com/en-.../hxet6xwx.aspx

Secondly, you can create custom validation logic on the client. To read further:

http://http://msdn.microsoft.com/en-.../f5db6z8k.aspx
Dec 6 '09 #3
Frinavale
9,735 Recognized Expert Moderator Expert
I just want to add to Sanjib65 response.

You have to use JavaScript to display a "MsgBox" in ASP.NET

MsgBox isn't going to work very well for you. You could force it to use MsgBox (quite easily) but in order for MsgBox to work it has to use the Windows.Forms message box component. In order to use this component you'll have to run an ActiveX component in your web page.

ActiveX components only run in Internet Explorer and they are commonly prevented from running because they access the client's operating system. This can be very dangerous: the ActiveX control could be malicious in nature and anything from the web should be considered unsafe. Even if the ActiveX control is not malicious, it could be insecure and could open security vulnerabilities just by sitting on the client's computer.

So, ActiveX controls are always advised against. In a secure, well designed web application, web page should never be accessing the operating system. Especially if it's something as simple as displaying a message window.

JavaScript is a client-side scripting language that runs in the web browser. It does things that the server can't, like displaying a message box.

To display a message box using JavaScript you use: alert().

So, if your page doesn't validate you need to display a JavaScript alert with the message that you want to display to the user.

Please check out this article on how to use JavaScript in ASP.NET for more information.

Please know that it is easy to get around JavaScript (client-side) validation.
You should Always validate data provided by the user server side.

-Frinny
Dec 7 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5347
by: Peter Bassett | last post by:
In my ASP script I call Javascript for a msgbox after the user has submitted the form of their resume information. I saw this example as a way to get a msgbox onto the client from ASP since server side scripts can't send a msgbox to a client. <% Const DQ = """" Response.Write("<script language=VBScript>" & "MsgBox " & DQ & "Your Resume Information Has Been Sent to companyname" & DQ & "</script>") %>
3
3129
by: JT | last post by:
im trying to use the MsgBox function in the following to display an ASP MsgBox containing text retrieved from the db into a recordset <% set rsMessages= myRecordset msg_text = rsMessages.Fields("msg_text") msgbox(msg_text) %> this generates a permission denied error b/c msgbox needs to run client side
2
5984
by: js | last post by:
Hi all, I currently encounter a problem and it is urgent to me. After calling the MsgBox.Show(), the message box is shown with non-modal mode, what is the possible reason??? This only happen in the VB project, works fine in C# project. SystemModal and ApplicationModal MsgBoxStyle were all tried and there was no help.
4
3849
by: Lakrom | last post by:
Hi to all, how to put msgbox in this asp page, this send me a message Denied permission: 'MsgBox' <% Set Conn=server.createobject("ADODB.connection") Conn.open application("StrConRuta") set rs = Conn.Execute("select rut from encuestarutaparaiso where rut='" & rut_usuario & "'") if not rs.eof then msgbox "Gracias por tu interes pera ya has respondido esta encuesta" end if Set rs= Conn.Execute("Select * from tabladatos where rut = '" &...
6
5063
by: Lapchien | last post by:
In this bit of code provided so helpfully by Nath: Private Sub Command118_Click() Dim rs As DAO.Recordset Set db = CurrentDb Set rs = db.openrecordset("IMPORT")
8
784
by: deko | last post by:
Can I close a MsgBox with VBA Code? Something like: If IsOpen (MsgBox, "Title") Then Close(MsgBox, "Title") Run some code Else Run other code End If Can this be done in VBA? Do I need to work with an API function?
2
1473
by: Radith Silva | last post by:
I need to use the MsgBox function like I used to in VB 6.0 So all i do is: MsgBox ("Please provide Input") BUT IN .NET: The error reads "msgbox is a namespace"
4
1594
by: James | last post by:
What does this mean? 'To specify more than the first argument, you must use the MsgBox function in an expression' I'd love to see an example. Thanks!
9
3420
by: Ivan Jericevich | last post by:
In my code below at the line 'response' a blip sound is heard and the program exits the sub -- No MsgBox is displayed. What am I doing wrong? If nonNumberEntered = True Then msg = "Enter numbers only" style = MsgBoxStyle.OkOnly title = "ERROR in cast"
2
4851
by: perkykoala | last post by:
I apologize in advance for being REALLY detailed/verbose. It's the result of staring/tweaking code for too long. Using VB 2005: I need to design a multiple choice test (unfortunately, I can't use radio buttons). How it works... Pre-1) File consists of the following format: Question 1 Choice 1
0
7971
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7893
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8276
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6698
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3932
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2408
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1495
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1243
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.