|
I am developing an application with several validation controls on the screen and the controls are working properly. On the screen I have an OK button, which causes control validation to occur, I also have a CLEAR button, incase the user wants to start over and blank everything out. When the user presses CLEAR, all the fields are set back to their default, "" in many cases. The CLEAR button is causing validation to occur and the user ends up with a bunch of messages saying that these fields can not be blank, in the ValidationSummary control.
The way I have the validation controls setup is to display an * next to the field in error and display the actual message in the Validation Summary.
I tried setting ShowMessages in the validation summary to false, but the * still show up next to the fields. Any idea how to turn off all validation if the CLEAR button is pressed?
Thank you,
Glenn
|
|
|
|
|
Hi Glenn. On your Clear button, set the CausesValidation property to false .
|
|
|
|
|
Ok, in no way am I a N00b at reading files! However, I was debugging some code today in which I was using a IO.StreamReader to read the text from a file and using an IO.StreamWriter to write it into a different file.
This file is about 3.2MB. The StreamReader DOES return the Correct Length of the File (IO.StreamReader.BaseStream.Length ). HOWEVER, while reading the file, the Stream THINKS it has reached the end, and like a good little programmer, I Flush the StreamWriter (BTW, I am flushing every 8096 Bytes - yes, that IS a lot of water!) but I am missing a HUGE chunk of data at the End of my file!
I have noticed that the IO.StreamReader.BaseStream.Position is usually TOTALLY different than the Sum of the Bytes returned for each re-iteration of retrieving data. For example, reading in 8096 Bytes at a time, when my Position variable thinks it's at 16,192, the BaseStream has it's internal buffer set to some other amount... Is this what's messing it up?
Notice however, it I REALLY want to waste a lot of memory and processing time, I can just read it all in at once (IO.StreamReader.ReadToEnd ) and then process it....GreeeEEEAAAaaaat!!! Just what I want! NOT!!!
So...what the @%$* is going on!??? How do I read the rest of the data!???
|
|
|
|
|
Wait a tick, it gets even better! I just discovered that it's Reading past the end of the File and returning more data than it should!
So, I know I need to use this handy-dandy Routine MS gave us: IO.StreamReader.DiscardBufferedData() . Soo, anyone have a clue as to how this should be done?? Any examples? Becuase the Help doesn't...well, help!
|
|
|
|
|
Ok, I found the answer to this. I'm sure most of you do not need this functionality and only use "ReadLine"... However, try parsing ANSI 835 files . (Yes, I'm aware there are 3rd party Libraries for this, but I hate them)
- The End
|
|
|
|
|
|
Sure thing, just curious if anyone would reply
'Function to Read a File into Cache so RegEx can be Performed
Private Sub CacheFile(ByVal File As String)
Dim ioReader As IO.StreamReader
Dim vBuffer() As Char
Dim hResult As Integer
'Exit if the File does not exist
If (File = "") Then Return
If (Not IO.File.Exists(File)) Then Return
If (Me._File <> File) Then Me._File = File Else Return
Try
'Initialize the Cache
_Cache = Nothing : _Cache = New System.Text.StringBuilder(8096)
'Read the File
ReDim vBuffer(8096)
ioReader = New IO.StreamReader(File, System.Text.Encoding.UTF8, True, 8096)
hResult = ioReader.Read(vBuffer, 0, vBuffer.Length) 'Read More Data
While (hResult > 0)
'There is a bug with a StreamReader. Sometimes more data is read than is neccessary.
'If these are the Last Bytes of data, only read up to the hResult
If (hResult < vBuffer.Length) Then _Cache.Append(vBuffer, 0, hResult) Else _Cache.Append(vBuffer, 0, vBuffer.Length)
hResult = ioReader.Read(vBuffer, 0, vBuffer.Length) 'Read More Data
End While
Catch ex As Exception : MsgBox(ex.ToString)
Finally
Erase vBuffer
If (Not IsNothing(ioReader)) Then ioReader.Close() : ioReader = Nothing
End Try
End Sub
|
|
|
|
|
In your code you have:
_Cache = Nothing : _Cache = New System.Text.StringBuilder(8096)
Isn't the first statement somewhat redundant?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
I don't trust VB nor the Garbage Collector
|
|
|
|
|
Hi,
most of us have read articles about list views
with controls like Textbox etc. added for editing functionality. This is nice but not sufficient if you want to cleanly display hierachical data.
Any suggestions on how to implement something similar with the TreeView?
For example a subnode would not be simple TreeNode but something like a Panel or similar on which one could put a TextBox for data input?
|
|
|
|
|
Infragistics Controls can do this...
|
|
|
|
|
|
Hi,
I wish to develop a WEB control in .NET ( or know of any such existing control) which works similar to the SQL Server table's data entry sheet.
to be more elaborate:
i will be specifying number of colums for that control.
2 rows with those many columns appears.
i fill in the data. and when i start filling the 2nd row
a 3rd empty row should appear.
|
|
|
|
|
|
i want to install visual studio .net, but i have a problem, i can`t install ie service pack, i don`t have connection to the internet. is it really true that u need to connect to internet. i`m running the update, copying from a friend. thanks
|
|
|
|
|
System requirements for VS.NET, full page here: http://msdn.microsoft.com/vstudio/productinfo/sysreqs/default.aspx[^]
Visual Studio .NET 2003 can be installed onto any of the following systems:
Microsoft Windows® Server 2003
Windows XP Professional
Windows XP Home Edition¹
Windows XP Media Center Edition
Windows XP Tablet PC Edition
Windows 2000 Professional (SP3 or later required for installation)
Windows 2000 Server (SP3 or later required for installation)
The install can update some packages from the Internet, but it is not required.
R.Bischoff .NET, Kommst du mit?
Great Freeware -> Abilon - Rss Reader | Zip Genius | SmartFTP
|
|
|
|
|
Hello guys,
Say, i need a little cheering up here...
I've been programming in .NET for over two and a half months now. And at this point i've come to the conclusion that i doubt .NET more than i doubt myself. IMHO a pretty dangerous situation. Back in mfc-days i used to spend two days on a problem before turning to internet to see if a MFC bug was involved. Now, in .NET, i turn to internet to see what bugs i can expect before i even put as little as a textbox on a form. Is this normal??
I absolutely adore C#. No doubt. And I must admit that .NET can be an incredibly powerful platform. Moreover, i'm convinced that it once WILL be. So, i will try to hang on to it as long as possible. But then again... boy... am i glad i skipped version 1.0!
Please tell me i'm wrong!
Ok, a few examples:
- A textbox without a border cuts off the lower parts of characters like y, p and g. Mainly in fontsize 11 with AutoSize turned ON.
- Listviews don't display item images when put on a usercontrol in a usercontrol. And the headers have serious painting errors.
- Listboxes don't always fire their click events.
- Tabpages cannot be disabled or hidden.
- When i move a project to another location, i always do a complete rebuild. Of the project itself and of any other projects involved. Compiles with no errors. Two weeks later, for no apparent reason, the program crashes on the exception that there are no appropriate resources compiled into the control. Rebuild all... no errors! Run it... and crash!!
- Every now and then controls dissapear from the designer. Takes a few rebuilds and IDE restarts to get them back on... most of the time... yet not always.
- I need a virtual listview... nope. The solution? Unwrap the .NET control piece by piece until it is stripped to the bare Win32 control and use the API and messages like we used to. Only... this time lookup the old header files to get all the constants, change "defines" into "const int", don't forget the WndProc and spend another hour packing all the structs into the right marshalling format. ALL my controls have at least two platform invokes!! And this is the only solution that is proposed over and over again. Everywhere you look for answers, they always boil down to "strip the .NET part and start programming like you used to...". But is that a future-stable solution?
- Some scrollbars are XP, while others stay Win95. Or was that Win3.11? And scrollbars tend to lie if you ask them if they are visible or not.
- A simple picturebox has no scrollbars!!
- When i start my old MFC software, ALL the controls and dialogs obey to the XP themes and colours. But not my .NET application!!?? I know, i know...
Application.EnableVisualStyles();
I DO that! Nevertheless, textbox backgrounds fail, and some dialogs too! While the least i had expected was to have visual consistency!
And these are only a few among many.
.NET is supposed to be the platform that rockets you into writing stable and gui-intensive software. Well... maybe... once it's debugged.
Ok, i'll stop nagging. Just please, tell me i'm wrong!
Thanx for bearing with me
Grtz,
Philippe
Philippe Dykmans
Software developpement
University of Antwerp
|
|
|
|
|
I think you have some valid complaints, I have some similar. However, .NET has really evolved programming in terms of having a really nice library (BCL) and OOP friendly way to design/develop n-tier applications.
I would bet that Microsoft will address many bugs/issues in future releases.
Happy coding.
R.Bischoff .NET, Kommst du mit?
Great Freeware -> Abilon - Rss Reader | Zip Genius | SmartFTP
|
|
|
|
|
Yes, that's true. .NET is a giant step in the good direction. When i wrote my complaint message i just had a terrible "buggy" and frustrating evening and felt the need to ventilate. Thanx for your reply!
Happy coding too,
Phil
Philippe Dykmans
Software developpement
University of Antwerp
|
|
|
|
|
I'm creating a prototype and have a simple control that I've derived from System.Windows.Forms.UserControl. I intend to be able to use this control in both a windows form client as well as to imbed it in a web page.
In order to get data into the control, I'm opening a tcp connection to my app server and requesting data, I am very familiar with tcp and have no problems there. Everything is working perfectly when I put the control into a windows form app.
My issue comes up when I plug the control into a web page. Now, I have configured the .NET CAS properly to grant appropriate permissions to the code using strong name evidence so I don't think I have a security problem with CAS.
But, I send in the tcp request from the web page, I am able to connect (I see the syn - syn/ack - ack in my sniffer) but then several requests are issued from my host to NETLOGON and some to port 445 (Microsoft directory services). Eventually (over 90 seconds later), my request completes (with my host sending psh-ack and getting fin-psh-ack) as expected. I just can't understand why the control is querying port 445 or what is going on. I don't see why my request is taking 90+ seconds from the time my connection opens until my request goes to the server...??
Any of you run across this before or have any suggestions?
thanks
Tim
|
|
|
|
|
Hello,
the Windows Service Manager provides some recovery options. In the properties of a service, you can select the computer's response if the service fails. For example, First failure >> Restart the Service. How can I announce the Windows Service Manager, that my own service fails, so that the recovery options start the work? Has anyone a code example?
Thanks in advance
Best regards,
Jan Lehmann [Germany]
|
|
|
|
|
If your service throws an unhandled exception, the SCM will handle it.
If your service terminates abruptly (such as it's process being killed), the SCM will handle it.
Process.GetCurrentProcess().Kill();
A really good way to get Windows to know your app failed most heinously is to use Interop and RaiseException and pass EXCEPTION_NONCONTINUABLE for the dwExceptionFlags parameter.
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
It's also probably a very good idea to log the service failure in the Windows Event Log, or publish it to WMI.
EventLog log = new EventLog(...);
log.Write(message, EventLogEntryType.Error);
Process.GetCurrentProcess().Kill();
It should be noted that forcibly terminating an application without at least attempting a graceful shutdown / release of resources is a bad idea. If possible, cleanup what you can before Kill ing the process.
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
Hi, I'm using the following code to get the Machine name in an app
System.Environment.MachineName
On most computers this works fine but on one of our testers computers (machine is a windows 2000 desktop pc, not a networking share either), it's throwing the following exception.
Request for the permission of type System.Security.Permissions.EnvironmentPermission, mscorlib, Version = 1.0.50000.0, Culture = neutral, publicKeyToken = blahblahblah failed.
I have no idea what is causing this. I tried messing around with the .Net Configuration. Figured mscorlib didn't have permission rights.
also.........
I can't get any computer information in general. Trying to do some WMI core queries as well from code and getting a "Security Error" Exception. Below is the code that gets the disk size.
public string GetsDiskSize(){
ManagementClass cimobject;
ManagementObjectCollection moc;
cimobject = new ManagementClass("Win32_DiskDrive");
moc = cimobject.GetInstances();
try { // BIOS INFO
foreach(ManagementObject mo in moc){
this.m_sDiskSize = GetSystemValue("Size",mo);
mo.Dispose();
break;
}
}
catch(Exception ex){
System.Windows.Forms.MessageBox.Show("GetsDiskSize " + ex.Message);
cimobject.Dispose();
moc.Dispose();
return ex.Message;
}
cimobject.Dispose();
moc.Dispose();
return this.m_sDiskSize;
}
|
|
|
|
|
Hi,
Try using
[ Assembly:EnvironmentPermission(SecurityAction.Assert)]
attribute for your class...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|