|
Hi all,
can anyone see anything glaringly wrong with this:
public class NumberBox : TextBox
{
protected override void OnKeyPress( KeyPressEventArgs e )
{
if( !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar) )
e.Handled = true;
base.OnKeyPress( e );
}
}
It doesn't have to be super-secure or anything (I don't care about Ctrl-V etc) cause I validate the control's Text later anyway, it's just a quick and easy way to persuade my lovely users to only enter numbers.
So I was just wondering if anyone can spot any usability problems with this? I'm not worried about
negative numberspasting in incorrect data, etcdecimal points and thousand seperatorsTIA,
Pete
|
|
|
|
|
Looks fine to me! Are you getting errors?
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
No, I was just wondering if there were some subtle caveats that I'd missed - that always seems to be the way when I play with new class libraries
|
|
|
|
|
You're still calling base.OnKeyPress , which will just let TextBox handle it. Your code should read:
if ( !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar) )
{
e.Handled = true;
return;
}
base.OnKeyPress(e);
|
|
|
|
|
I know I'm still calling OnKeyPress(). It seems to work that way, because e.Handled = true. I wasn't sure wether to call it or not, I figured that it was best to call it just in case the Framework has to do some kind of housekeeping.
|
|
|
|
|
Nah, the e.Handled takes care of the underlying Win32 housekeeping behind the scenes.
[I'm sure you realize this, but my comments below are for our gentle OOP neophytes out there...]
You should only call base functions a) if they're required (see the reference dox for the base methods) or b) if you wish to use the default base implementation.
In the case of your derived TextBox class, you wouldn't want to call base.OnKeyPress() because you don't want the default behavior.
|
|
|
|
|
I see what you mean.
I guess I'm finding it a little hard to get used to C# properties. It didn't really occur to me that a simple boolean 'assignment' could actually kickoff a lot of behind-the-scenes processing.
My thinking was "Ok, I'll set e.Handled then pass it to the base method so it knows I've dealt with it" Baby steps...
Thanks Ian,
Pete
|
|
|
|
|
I've got a .NET class that's being hosted for remoting by IIS (NOT a WebService). Works fine, except for debugging it...
How can I debug it with Visual Studio.NET? What kind of VS.NET project would I use? In particular, how can I configure VS.NET to allow me to breakpoint in the remoted class?
Thanks!
|
|
|
|
|
I recieve this error when running the Hello World .NET sample web service on windows XP Professional with IIS 5x. What am I missing?
Regards,
Ron
System.IO.FileNotFoundException: File or assembly name ogvvgnwu.dll, or one of its dependencies, was not found.
File name: "ogvvgnwu.dll"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings)
at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
Fusion log follows:
=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\WINDOWS\TEMP\ogvvgnwu.dll
LOG: Appbase = file:///c:/inetpub/wwwroot/RainMakerLists
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WINDOWS/TEMP/ogvvgnwu.dll.
|
|
|
|
|
|
What I really need to know is where is the uninstall program/msi for the .NET framework?
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
|
You should probably rebuild your machine, but as a last resort, you could use the Windows Installer Cleanup utility to remove the references to the beta.
http://support.microsoft.com/default.aspx?scid=KB;en-us;q240116[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Thanks so much for your info! The Installer Cleanup Utility did it! I'm very relieved, because I could not afford the 12+ hours it would take to rebuild.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
How can I get the same graphic user interface form browser and form applications in DotNet?
Thanks,
Renato Oliveira
|
|
|
|
|
VS.NET IDE / Toolbox / Right-click / Customize / Browse Microsoft Internet Explorer. Drag&drop it onto your form. You are done (almost).
|
|
|
|
|
We have a server product for which third-parties can create installable applications. The applications are written as COM components. As such, we've generated a pair of Primary Interop Assemblies for the components needed for the application to talk to the server.
We've created a deployment package using Visual Studio.NET which installs the PIAs to the Global Assembly Cache. It doesn't however currently install to the Primary Interop Assemblies directory from which VS.NET finds available PIAs.
I can create a 'Program Files\Microsoft.NET\Primary Interop Assemblies' directory as part of the installer; is this going to work on non-English systems, or should I be trying to find the right folder through the registry, or some Windows Installer property?
<shameless plug> More info on the server at http://www.5d.co.uk/Meteor.htm.
--
Mike Dimmick
|
|
|
|
|
You can install assemblies anywhere you want.
|
|
|
|
|
I possibly didn't explain this well enough.
We're supplying the server software as a single kit, including both the server itself and the software development kit for developing third-party applications.
Visual Studio.NET will display in the References dialog's .NET tab any assemblies installed in the Primary Interop Assemblies directory. On an English system, this directory defaults to %ProgramFiles%\Microsoft.NET\Primary Interop Assemblies (by default, this contains the PIAs for e.g. classic ADO [in adodb.dll]). Installing in this directory means that the developer doesn't have to browse for the PIAs.
What I wanted to know was, is the name of this directory (i.e. %ProgramFiles%\Microsoft.NET\Primary Interop Assemblies) the same on all locales, or is it localised?
Since the PIAs reference COM components, we install a copy into the Global Assembly Cache (GAC) for run time, but VS.NET and the compile tools don't appear to look there at design time or compile time.
--
Mike Dimmick
|
|
|
|
|
Mike Dimmick wrote:
%ProgramFiles%\Microsoft.NET\Primary Interop Assemblies
is not a place to put your own assemblies. That's a place where the .NET run-time put his own assemblies.
In fact, you can create a registry key under HKLM \ Microsoft \ .NETFramework \ AssemblyFolders. All the keys at this level are places taken automatically into account, ie the user does not need to explicitely browse.
|
|
|
|
|
Hey how do i debug an assembly which is referenced from my asp.net application and how to debug an assembly which is referenced from another assembly.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
In VB6 you used to be able to have strings that had embedded nulls. I can't seem to find this functionality in the .Net Frame work. My problem is I have binary data that I need to convert into a string in order to hand that data to a ActiveX COM control. However, after I convert the data over to a string in .Net I loose all of the string past the first null.
I must be missing something. Is there a way around this
Thanks
Nick
Forever Developing
|
|
|
|
|
Nicholas Cardi wrote:
My problem is I have binary data that I need to convert into a string in order to hand that data to a ActiveX COM control
I would directly marshall the byte array to a BSTR. (MarshalAs attribute).
|
|
|
|
|
Hi,
How can I find the names and/or IPs of the computers on my LAN (the ones that I see in Explorer)? Please help, I really don't have a clue...
Thanks a lot!
Andrei Matei
andreimatei@home.ro
|
|
|
|
|
use Active Dirctory or
use System.Net or
use LDAP queries or
use System.Net.Dns or
hi
|
|
|
|