473,382 Members | 1,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Msgbox

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 2491
sanjib65
102 100+
You can specify that a user must provide information in a specific control on an ASP.NET Web page by adding a RequiredFieldValidator control to the page and linking it to the required control.
The steps are:
1) Add a RequiredFieldValidator control to the page and set the following properties:

ControlToValidate: 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 100+
I have forgotten to add one more thing. Besides Framework Validation controls you can Validate Programmatically 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 Expert Mod 8TB
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
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...
3
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 =...
2
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...
4
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 =...
6
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
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...
2
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
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
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...
2
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.