.NET Forum / ASP.NET / General / June 2007
Object reference not set to an instance of an object
|
|
Thread rating:  |
dancer - 27 May 2007 14:38 GMT Using VB.net and ASP.net
At runtime I receive the error that MANY people receive who are using much more complicated code than mine.
"Object reference not set to an instance of an object. "
I know WHY it's happening. It is when a selection is not made to a RadioButtonList, so the item is = to nothing.
I have a RequiredFieldValidator, but the runtime error obviously shows before the validator can act.
The advice given on this error is that "You are trying to use a reference variable whose value is Nothing"
How can I make the RequiredFieldValidator work BEFORE this runtime error occurs?
Alexey Smirnov - 27 May 2007 15:20 GMT > Using VB.net and ASP.net > [quoted text clipped - 14 lines] > How can I make the RequiredFieldValidator work BEFORE this runtime error > occurs? What's your code for validator? Have you set the ControlToValidate?
some code that should work
<asp:RadioButtonList ID="ccType" Font-Names="Arial" RepeatLayout="Flow" runat="server"> <asp:ListItem>MasterCard</asp:ListItem> <asp:ListItem>Visa</asp:ListItem> </asp:RadioButtonList>
<asp:RequiredFieldValidator ID="ccTypeReqVal" ControlToValidate="ccType" ErrorMessage="Card Type. " Display="Static" InitialValue="" Font-Names="Verdana" Font-Size="12" runat="server"> * </asp:RequiredFieldValidator>
dancer - 27 May 2007 15:52 GMT My validator code is ok. I copied it to another file, and it worked fine. Are you game to look at the rest of my code? If so, I will copy it here.
Thanks
>> Using VB.net and ASP.net >> [quoted text clipped - 32 lines] > * > </asp:RequiredFieldValidator> Alexey Smirnov - 27 May 2007 16:07 GMT > My validator code is ok. I copied it to another file, and it worked fine. > Are you game to look at the rest of my code? If so, I will copy it here. Is it the same as in your previous post? http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_t hread/thread/945034592e203207
add a RequiredFieldValidator for the EmpCaution
otherwise send me a code, I will check it, no problem :-)
dancer - 27 May 2007 16:31 GMT Yes. I just looked at your reply there:
"I think, you forgot to add a RequiredFieldValidator for the EmpCaution list "
I don't have a RequiredFieldValidator for that or some others, because I'm limiting my testing. The less code I have, the less to confuse me. I always enter a selection for those radiobutton lists when testing the EmpTrain list. I get the runtime error ONLY when I don't enter a selection for those OR for the EmpTrain list [even though the EmpTrain list has a validator]
Did that paragraph make any sense?
Thank you. If you can find any reason for the error, I will be eternally grateful!
>> My validator code is ok. I copied it to another file, and it worked >> fine. [quoted text clipped - 6 lines] > > otherwise send me a code, I will check it, no problem :-) Alexey Smirnov - 27 May 2007 18:19 GMT > I don't have a RequiredFieldValidator for that or some others, because I'm > limiting my testing. The less code I have, the less to confuse me. I > always enter a selection for those radiobutton lists when testing the > EmpTrain list. I get the runtime error ONLY when I don't enter a selection > for those OR for the EmpTrain list [even though the EmpTrain list has a > validator] Using ClientTarget="downlevel" you render old browsers-compatible code without javascript validation and any other client-side server control functionality. Get rid of the ClientTarget and validation will work again.
ASP.NET Web Server Controls and Browser Capabilities http://msdn2.microsoft.com/en-us/library/x3k2ssx2.aspx
dancer - 27 May 2007 20:36 GMT WHAT A RELIEF!!! Thank you Alexey!!! It works on my local computer, BUT when I download it to my server, it won't even let me see the page. I get this message:
Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration>
>> I don't have a RequiredFieldValidator for that or some others, because >> I'm [quoted text clipped - 12 lines] > ASP.NET Web Server Controls and Browser Capabilities > http://msdn2.microsoft.com/en-us/library/x3k2ssx2.aspx Alexey Smirnov - 27 May 2007 20:59 GMT > WHAT A RELIEF!!! > Thank you Alexey!!! It works on my local computer, Great, glad you fixed it.
> BUT when I download > it to my server, it won't even let me see the page. I get this message: Go to the web.config file on your server and change customErrors to Off
<customErrors mode="Off"/>
You should see a real error message then.
dancer - 29 May 2007 23:03 GMT Sorry to be so dumb, but how do I get to web.config file on my server?
Thanks you
>> WHAT A RELIEF!!! >> Thank you Alexey!!! It works on my local computer, [quoted text clipped - 10 lines] > > You should see a real error message then. Alexey Smirnov - 29 May 2007 23:17 GMT > Sorry to be so dumb, but how do I get to web.config file on my server? You should have a local copy of it, make a change and copy back (e.g. via FTP)
dancer - 29 May 2007 23:59 GMT I am communicating with my server by FrontPage, not ftp. I called my server and asked, "How do I get to the web.config file?" He answered, "What's that?"
> Sorry to be so dumb, but how do I get to web.config file on my server? > [quoted text clipped - 14 lines] >> >> You should see a real error message then. Alexey Smirnov - 30 May 2007 00:30 GMT > I am communicating with my server by FrontPage, not ftp. > I called my server and asked, "How do I get to the web.config file?" > He answered, "What's that?" Huh, a FrontPage? I'm not sure how it is working there, but as far as I remember it has a site browser with all the files, I'm right? The main web.config file is located in the root directory of your web site. A web.config file could be located also in a sub-directories of an application, but I think you don't use such case. So, look in the root. If you have one, open it in FrontPage or copy a new one from your local box.
How To Create the Web.config File for an ASP.NET Application http://support.microsoft.com/kb/815179
dancer - 31 May 2007 18:27 GMT Hi Alexey, There was not a web.config file on my web at the server. They created one. Now I get errors which are no problem on my own computer. I notice that at the end of the errors page is this:
Version Information: Microsoft .NET Framework Version:1.1.4322.2379; ASP.NET Version:1.1.4322.2379
While on MY computer there is this:
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
Would that have anything to do with it? If so, what can I do?
>> I am communicating with my server by FrontPage, not ftp. >> I called my server and asked, "How do I get to the web.config file?" [quoted text clipped - 10 lines] > How To Create the Web.config File for an ASP.NET Application > http://support.microsoft.com/kb/815179 Juan T. Llibre - 31 May 2007 18:37 GMT That error message means that, at the server, the application is running against the .Net Framework 1.1, while at your computer it's running against the .Net Framework 2.0.
You will need to set the application to run against the .Net Framework 1.1 and your problems will go away.
Open the IIS Manager, right click the application, and select the "ASP.NET" tab; then, select the .Net Framework 1.1 from the dropdown and OK your way out.
Stop and restart IIS ( from a "Run", cmd ) : iisreset
...and everything should work fine.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ======================================
> Hi Alexey, > There was not a web.config file on my web at the server. They created one. [quoted text clipped - 24 lines] >> How To Create the Web.config File for an ASP.NET Application >> http://support.microsoft.com/kb/815179 Juan T. Llibre - 31 May 2007 18:40 GMT re: !> You will need to set the application to run against !> the .Net Framework 1.1 and your problems will go away.
Oops... that's backwards.
You will need to set the application, at the server, to run against the .Net Framework 2.0 and your problems will go away.
Open the server's IIS Manager, right click the application, and select the "ASP.NET" tab; then, select the .Net Framework 2.0 from the dropdown and OK your way out.
Stop and restart the server's IIS ( from a "Run", cmd ) : iisreset
...and everything should work fine.
Sorry about the instruction reversal.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ======================================
> That error message means that, at the server, the application is running > against the .Net Framework 1.1, while at your computer it's running [quoted text clipped - 43 lines] >>> How To Create the Web.config File for an ASP.NET Application >>> http://support.microsoft.com/kb/815179 dancer - 01 Jun 2007 16:02 GMT I am so irritated! My server - which is BellSouth.net - which is now AT&T - does not have .Net Framework 2.0 installed. Are they not WAY behind??!!
If I go backward, will much of my code have to be re-written?
Thank you.
> re: > !> You will need to set the application to run against [quoted text clipped - 70 lines] >>>> How To Create the Web.config File for an ASP.NET Application >>>> http://support.microsoft.com/kb/815179 Alexey Smirnov - 01 Jun 2007 19:35 GMT > I am so irritated! My server - which is BellSouth.net - which is now AT&T - > does not have .Net Framework 2.0 installed. > Are they not WAY behind??!! maybe it simply not yet configured for your web site?
dancer - 01 Jun 2007 20:38 GMT This is what they say. Unfortunately we are unable to fulfill this request. We do upgrade our software as soon as possible, however, it does require that we go through a rigorous certification process first, to make sure that the new software does not conflict with any of the other software we have running, or our site management software. As soon as we are able to certify the newest version of the .NET framework, we will be upgrading the software on the servers to fully support it.
And this:
Dear Valued Customer:
Currently our admins do not ahave a time table on when testing for upgrading to the new .NET Framework will be started.
>> I am so irritated! My server - which is BellSouth.net - which is now >> AT&T - >> does not have .Net Framework 2.0 installed. >> Are they not WAY behind??!! > > maybe it simply not yet configured for your web site? Juan T. Llibre - 01 Jun 2007 20:05 GMT re: !> If I go backward, will much of my code have to be re-written?
Any code which runs against 2.0-specific objects will fail.
Do *you* have the .Net Framework 1.1 installed ?
If you do, the best way to know whether your code will run is to install the Web Matrix ( http://www.asp.net/webmatrix/ ) which has a development web server, just like Visual Studio and VWD have.
It's only a 1.3MB download.
If the code runs within the Web Matrix development server, you're good to go.
If not, you can make the needed changes right in the Web Matrix IDE, so your code *will* run against ASP.NET 1.1.
Of course, you can also ask your AT&T ISP whether they can support ASP.NET 2.0. I'd find it really odd if they did not support ASP.NET 2.0.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ======================================
>I am so irritated! My server - which is BellSouth.net - which is now AT&T - does not have .Net >Framework 2.0 installed. [quoted text clipped - 74 lines] >>>>> How To Create the Web.config File for an ASP.NET Application >>>>> http://support.microsoft.com/kb/815179 dancer - 01 Jun 2007 21:02 GMT They support Asp.net 1.1 only. I already know my code fails on the server. There don't seem to be any tutorials on 1.1, only 2.0 Does the Web Matrix tell you HOW to make the changes?
> re: > !> If I go backward, will much of my code have to be re-written? [quoted text clipped - 107 lines] >>>>>> How To Create the Web.config File for an ASP.NET Application >>>>>> http://support.microsoft.com/kb/815179 dancer - 02 Jun 2007 02:28 GMT After having the webmatrix page check to see if I had the proper Net Framework installed, I installed Web Matrix Project. I read on the "getting started" page of the Walk Through ".NET Framework Version 1.0.3705.0"
But when I made my first little page and ran it, I got an error and this version at the bottom:
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
I was very careful to choose "Use ASP.NET Web Matrix Server" when I told it to run.
I thought Net Framework 1.1 had been installed before on my computer. But I could not find it in the Administrative Tools - only 2.0. So I downloaded it and answered Yes to install. It still is not in the Administrative Tools. I did a search and there is a Net Framework 1.1 config and 1.1 wizard in the Administrator\Corp\Start Menu\Programs\ Administrative Tools only.
Where would it be and how do I get it to where I need it?
> re: > !> If I go backward, will much of my code have to be re-written? [quoted text clipped - 107 lines] >>>>>> How To Create the Web.config File for an ASP.NET Application >>>>>> http://support.microsoft.com/kb/815179 Juan T. Llibre - 02 Jun 2007 03:45 GMT re: !> I did a search and there is a Net Framework 1.1 config and 1.1 wizard in the !> Administrator\Corp\Start Menu\Programs\ Administrative Tools only.
You have it installed, then. You don't need to run those, except for very special needs.
After installing the .Net Framework 1.1, the Web Matrix's dev server should be able to run your 1.1 pages.
You don't have to change the .Net Framework version for the app to 1.1 if you're going to use the development server built into the Web Matrix but, to be on the safe side with IIS, switch the .Net Framework version for your app to 1.1.
Right-click the app in the IIS Manager, select "Properties" and then select the "ASP.NET" tab; then switch the version from the dropdown.
That way, you can double-check the code in IIS, too.
As far as Web Matrix goes, just copy/paste your current app's pages into the Web Matrix IDE, one by one, and run them.
If there's anything specific to the .Net Framework 2.0, it will throw an error and you can change the code or the object.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ======================================
> After having the webmatrix page check to see if I had the proper Net Framework installed, I > installed Web Matrix Project. I read on the "getting started" page of the Walk Through ".NET [quoted text clipped - 118 lines] >>>>>>> How To Create the Web.config File for an ASP.NET Application >>>>>>> http://support.microsoft.com/kb/815179 dancer - 04 Jun 2007 22:27 GMT I have downloaded and installed Net Framework 1.1 yet again. I removed Web Matrix from my computer, downloaded it again and installed it again. When I open the program, the first page, as it is opening, says Net Framework 2. When I run a little program with an error in it, the compiler says Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210 ?????
> re: > !> I did a search and there is a Net Framework 1.1 config and 1.1 wizard [quoted text clipped - 166 lines] >>>>>>>> How To Create the Web.config File for an ASP.NET Application >>>>>>>> http://support.microsoft.com/kb/815179 Alexey Smirnov - 05 Jun 2007 20:39 GMT > I have downloaded and installed Net Framework 1.1 yet again. > I removed Web Matrix from my computer, downloaded it again and installed it [quoted text clipped - 5 lines] > Version:2.0.50727.210 > ????? It means you have .NET 2.0 installed and configured for the web site.
What's the problem?
dancer - 06 Jun 2007 00:07 GMT I had created a file using ASP.net 2.0. It ran against (or with) Framework 2.0 on my computer. It compiled and ran fine. I transferred it to my hosting server and got errors. I then found out that my hosting server supports only Framework 1.1 and ASP.net 1.1. Juan Libre recommended that I download WebMatrix Project, which runs with 1.1 to see where my code needed to be changed to be compatible wth my hosting server. BUT it keeps saying 2.0, so how can I make changes for 1.1?
>> I have downloaded and installed Net Framework 1.1 yet again. >> I removed Web Matrix from my computer, downloaded it again and installed [quoted text clipped - 11 lines] > > What's the problem? Juan T. Llibre - 06 Jun 2007 00:53 GMT re: !> Juan Libre recommended that I download WebMatrix Project, which runs with !> 1.1 to see where my code needed to be changed to be compatible wth my hosting server. !> BUT it keeps saying 2.0, so how can I make changes for 1.1?
Do you have the .Net Framework 1.1 installed in your home computer ? ( whereever you are doing the development work... )
If not, you need to install it.
If the .Net Framework 1.1 isn't installed, download it from : http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157 -034d1e7cf3a3&DisplayLang=en
...and install it ( 23MB download ).
As soon as you install it, download the .Net Framework Service Pack 1 : http://www.microsoft.com/downloads/details.aspx?familyid=A8F5654F-088E-40B2-BBDB -A83353618B38&displaylang=en
...and install *that*.
After you've installed them both you should see an ASP.NET tab in the IIS Manager, when you right-click your application.
Click the tab...and change the ASP.NET version to 1.1.4322.
Your problems will be on the way to being solved at that point.
You may still have object problems, but you can code your way around them by reading the error messages and changing the code.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ======================================
>I had created a file using ASP.net 2.0. It ran against (or with) Framework 2.0 on my computer. It >compiled and ran fine. [quoted text clipped - 17 lines] >> >> What's the problem? dancer - 31 May 2007 18:44 GMT Here is an error that comes up on the server. But this line compiles fine on my computer Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'Text' is not a member of 'System.Web.UI.WebControls.CheckBoxList'.
Source Error:
Line 28: Dim TheNature As String = nature.Text Line 29: Dim TheNatureNew As String Line 30: Dim TheIndicate As String = Indicate.Text Line 31: Dim TheAction As String = action.Text Line 32: Dim TheActionNew As String
Source File: e:\accounts\whee13\WWW\juan_radio32.aspx Line: 30
Show Detailed Compiler Output:
c:\windows\system32\inetsrv> "c:\windows\microsoft.net\framework\v1.1.4322\vbc.exe" /t:library /utf8output /R:"c:\windows\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll" /R:"c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll" /R:"c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll" /R:"c:\windows\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /R:"c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll" /R:"c:\windows\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll" /R:"c:\windows\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\abc4b73d\d202bb95\r8nbr8x9.dll" /debug- /win32resource:"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\abc4b73d\d202bb95\r8nbr8x9.res" "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\abc4b73d\d202bb95\r8nbr8x9.0.vb"
Microsoft (R) Visual Basic .NET Compiler version 7.10.7017.4 for Microsoft (R) .NET Framework version 1.1.4322.2379 Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
e:\accounts\whee13\WWW\juan_radio32.aspx(30) : error BC30456: 'Text' is not a member of 'System.Web.UI.WebControls.CheckBoxList'.
Dim TheIndicate As String = Indicate.Text ~~~~~~~~~~~~~
Also this was one of many lines under "complete compilation source" Line 268: Protected Indicate As System.Web.UI.WebControls.CheckBoxList
Thanks!
>> I am communicating with my server by FrontPage, not ftp. >> I called my server and asked, "How do I get to the web.config file?" [quoted text clipped - 10 lines] > How To Create the Web.config File for an ASP.NET Application > http://support.microsoft.com/kb/815179 Alexey Smirnov - 31 May 2007 19:03 GMT > Here is an error that comes up on the server. But this line compiles fine > on my computer [quoted text clipped - 5 lines] > Compiler Error Message: BC30456: 'Text' is not a member of > 'System.Web.UI.WebControls.CheckBoxList'. CheckBox Control has no Text property in .NET 1.0-1.1 http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.checkboxlist_ members(vs.71).aspx
dancer - 27 May 2007 21:03 GMT ONE OTHER THING WITH THE FOLLOWING: If Checkemp.Checked Then
Empornon = "Employee"
ElseIf Checknon.checked Then
empornon= "Non-Employee"
Else Empornon = ""
End If
-------------------------------------------------
I don't want the user to be able to check both employee and non-employee or only one. A RequiredField Validator won't work here. How can I ensure that the user checks 1 or both?
If neither are checked I get this message: "Input string was not in a correct format"
Thank you again.
>> I don't have a RequiredFieldValidator for that or some others, because >> I'm [quoted text clipped - 12 lines] > ASP.NET Web Server Controls and Browser Capabilities > http://msdn2.microsoft.com/en-us/library/x3k2ssx2.aspx Alexey Smirnov - 27 May 2007 21:21 GMT > I don't want the user to be able to check both employee and non-employee or > only one. A RequiredField Validator won't work here. How can I ensure that > the user checks 1 or both? A RadioButton (RadioButtonList) will give you a single value selection.
dancer - 29 May 2007 14:32 GMT But I want to be sure he checks one or both. I understand that you can't use a validator with a radio button. Also I get an error if it is not checked.
??
>> I don't want the user to be able to check both employee and non-employee >> or [quoted text clipped - 3 lines] > > A RadioButton (RadioButtonList) will give you a single value selection. Alexey Smirnov - 29 May 2007 15:10 GMT > But I want to be sure he checks one or both. I understand that you can't > use a validator with a radio button. > Also I get an error if it is not checked. ??
You said "I ***don't*** want the user to be able to check both employee and non-employee"
> But I want to be sure he checks one or both. So, is it possible to be an Employee and Non-Employee in the same time?
dancer - 29 May 2007 19:11 GMT I think I was taking a nap when I wrote that. I MEANT to say I WANT the user to check either one or both. It is possible that 2 people are hurt in the same accident - one an employee and the other a non-employee.
>> But I want to be sure he checks one or both. I understand that you can't >> use a validator with a radio button. [quoted text clipped - 9 lines] > So, is it possible to be an Employee and Non-Employee in the same > time? dancer - 29 May 2007 19:19 GMT OOPS - There's a flaw in my if- then logic. The variable "Empornon" cannot be equal to both.
>I think I was taking a nap when I wrote that. I MEANT to say I WANT the >user to check either one or both. [quoted text clipped - 15 lines] >> So, is it possible to be an Employee and Non-Employee in the same >> time? Alexey Smirnov - 29 May 2007 19:40 GMT > OOPS - There's a flaw in my if- then logic. The variable "Empornon" cannot > be equal to both. So, is it working now, or you still need a help? :-)
Let me know
dancer - 29 May 2007 20:36 GMT What is wrong with my logic here? It returns "employee" if I check both.
If Checkemp.Checked AndAlso Checknon.checked Then
Empornon = "both"
ElseIf Checkemp.Checked Then
Empornon = "Employee"
ElseIf Checknon.checked Then
empornon= "Non-Employee"
Else Empornon = ""
End If
>> OOPS - There's a flaw in my if- then logic. The variable "Empornon" >> cannot [quoted text clipped - 3 lines] > > Let me know Alexey Smirnov - 29 May 2007 20:52 GMT > What is wrong with my logic here? It returns "employee" if I check both. The code looks correct. Try to check the values before
Response.Write(Checkemp.Checked) Response.Write(Checknon.Checked)
dancer - 29 May 2007 21:33 GMT My logic is working. Now, how do I make sure the user checks one or other or both? If I validate each text box it will make him answer both, even if it's only one.
Thanks
>> What is wrong with my logic here? It returns "employee" if I check both. > > The code looks correct. Try to check the values before > > Response.Write(Checkemp.Checked) > Response.Write(Checknon.Checked) Alexey Smirnov - 29 May 2007 21:45 GMT > My logic is working. > Now, how do I make sure the user checks one or other or both? > If I validate each text box it will make him answer both, even if it's only > one. If you have a question regarding code, you have to send that code.
I don't see your validation rule, how can I answer? :-)
dancer - 29 May 2007 22:37 GMT I don't have code for that yet. It is a question of concept. Is there a control to verify that if one check box is not checked, then the other is?
Thank you
>> My logic is working. >> Now, how do I make sure the user checks one or other or both? [quoted text clipped - 5 lines] > > I don't see your validation rule, how can I answer? :-) Alexey Smirnov - 29 May 2007 22:51 GMT > I don't have code for that yet. It is a question of concept. Is there a > control to verify that if one check box is not checked, then the other is? As far as I remember you have to do a custom validator for checkbox. But... why don't you like your own code?
If Checkemp.Checked AndAlso Checknon.checked Then Empornon = "both" ElseIf Checkemp.Checked Then Empornon = "Employee" ElseIf Checknon.checked Then empornon= "Non-Employee" Else Empornon = "" End If
This gives you a value of Empornon (both, Employee, Non-Employee or empty string). As I understand, you need to show an error when Empornon is empty, right?
So, simply add
If Empornon = "" Then Response.Write("ERROR: please define your status") Exit Sub End If
dancer - 30 May 2007 00:03 GMT WHAT A HELP YOU ARE ALEXEY!!! Could you also tell me how to make the Response.Write write in red? The validator response text is all in red, but I didn't tell it to be in red. Is this a default for all validator text, or am I missing something?
>> I don't have code for that yet. It is a question of concept. Is there a >> control to verify that if one check box is not checked, then the other [quoted text clipped - 22 lines] > Exit Sub > End If Alexey Smirnov - 30 May 2007 00:23 GMT > WHAT A HELP YOU ARE ALEXEY!!! > Could you also tell me how to make the Response.Write write in red? > The validator response text is all in red, but I didn't tell it to be in > red. Is this a default for all validator text, or am I missing something? You are missing a HTML telling that the text must be in red :-)
Response.Write("<font color=""red"">This message is in red.</font>")
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|