﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WebForms (How do I?)  » Null Dates in Webforms, How?</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Thu, 14 May 2026 11:39:31 GMT</lastBuildDate><ttl>20</ttl><item><title>Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13228.aspx</link><description>How do I properly use null dates in a webforms application?&amp;nbsp; When working with null dates I get data binding errors on postbacks.&amp;nbsp; We use nulls to at least have a nominally empty date field but can't seem to get it to work in webforms.&amp;nbsp; I searched mutiple times and can't find any references to what the best way to do it so that customers won't see a date when entering data if the field is not supposed to have a date in it yet.&amp;nbsp; I've tried the return alternate using #1/1/1800# and then that shows in the textbox on the screen, I could live with the return alternate concept if it just didn't show in textboxes and listviews.&lt;/P&gt;&lt;P&gt;Is there an easy way to do this or do I need to not bind the data and handle it myself? (which is what I'm trying to avoid).</description><pubDate>Sat, 09 Feb 2008 11:50:04 GMT</pubDate><dc:creator>Cyrus Welch</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost14238.aspx</link><description>[quote]I do need to create a seperate assembly containing any subclassed controls I want to use and then I can reference them and use the controls?[/quote]&lt;/P&gt;&lt;P&gt;Yup...this is exactly what you should do.&amp;nbsp; This is the very same thing that we do for all of our applications as well as our web applications.&amp;nbsp; So just create a class library, add all of your subclassed controls, then you can use them instead of the standard controls.&amp;nbsp; This is good programming standards...good job :)</description><pubDate>Sat, 09 Feb 2008 11:50:04 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost14226.aspx</link><description>[quote][b]Trent L. Taylor (02/05/2008)[/b][hr]Cyrus,&lt;P&gt;Once you create the class, make sure that your web application has a reference to the assembly that houses the class you created.&amp;nbsp; You can also turn on the AutoPopulateToolbox option for it to show in your toolbox...or just type in the name of the namespace and class when defining the object.&lt;/P&gt;&lt;P&gt;To turn on the AutoPopulation of the toolbox click Tools-&amp;gt;Options-&amp;gt;Windows Forms Designer-&amp;gt;General-&amp;gt;AutoToolboxPopulate .&lt;/P&gt;&lt;P&gt;I know that it says "Windows Forms" but this populates the Web controls as well.[/quote]&lt;P&gt;Just to clarify what I am going to try here, I do need to create a seperate assembly containing any subclassed controls I want to use and then I can reference them and use the controls?&amp;nbsp; I think I can work with that.&amp;nbsp; I have some other questions on whether I can do some things or not but I'll start another thread for that.</description><pubDate>Fri, 08 Feb 2008 17:41:59 GMT</pubDate><dc:creator>Cyrus Welch</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost14004.aspx</link><description>Cyrus,&lt;/P&gt;&lt;P&gt;Once you create the class, make sure that your web application has a reference to the assembly that houses the class you created.&amp;nbsp; You can also turn on the AutoPopulateToolbox option for it to show in your toolbox...or just type in the name of the namespace and class when defining the object.&lt;/P&gt;&lt;P&gt;To turn on the AutoPopulation of the toolbox click Tools-&amp;gt;Options-&amp;gt;Windows Forms Designer-&amp;gt;General-&amp;gt;AutoToolboxPopulate .&lt;/P&gt;&lt;P&gt;I know that it says "Windows Forms" but this populates the Web controls as well.</description><pubDate>Tue, 05 Feb 2008 09:55:44 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13996.aspx</link><description>[quote][b]Trent L. Taylor (01/31/2008)[/b][hr]Cyrus,&lt;P&gt;This is no different for web than it is for Windows.&amp;nbsp; The only difference is that you will want to create a class library that your web site or web application references to house all of your custom (or inherited) controls.&amp;nbsp; Here is how you would subclass a web textbox:&lt;/P&gt;&lt;P&gt;[codesnippet]Public Class MyWebTextBox&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits MicroFour.StrataFrame.UI.Web.TextBox&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.OnTextChanged(e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;BR&gt;End Class[/codesnippet][/quote]&lt;P&gt;Ok, I've tried that without any success.&amp;nbsp; Does it have to be in it's own assembly to work?&amp;nbsp; When I create the subclass for the textbox I can't find any way to put it on a webform and actually use it.&amp;nbsp; This is where things are geting stuck.&amp;nbsp; Once I have created the subclassed control how do I use it, since I'm guessing that I have the subclassed control now, but I can't put on anything and use it.</description><pubDate>Mon, 04 Feb 2008 23:51:11 GMT</pubDate><dc:creator>Cyrus Welch</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13862.aspx</link><description>Cyrus,&lt;/P&gt;&lt;P&gt;This is no different for web than it is for Windows.&amp;nbsp; The only difference is that you will want to create a class library that your web site or web application references to house all of your custom (or inherited) controls.&amp;nbsp; Here is how you would subclass a web textbox:&lt;/P&gt;&lt;P&gt;[codesnippet]Public Class MyWebTextBox&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits MicroFour.StrataFrame.UI.Web.TextBox&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.OnTextChanged(e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;BR&gt;End Class[/codesnippet]</description><pubDate>Thu, 31 Jan 2008 09:37:06 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13852.aspx</link><description>This is all well and good, but all the examples seem to be for windows forms and don't seem to work for webforms.&amp;nbsp; All I want to do it subclass the control and be able to place it in my webform in place of the normal control.&amp;nbsp; I can't seem to do anything with a control created this way.&amp;nbsp; Am I missing something or is VS2005 broken on both my desktop and laptop?</description><pubDate>Wed, 30 Jan 2008 20:19:56 GMT</pubDate><dc:creator>Cyrus Welch</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13820.aspx</link><description>[quote]Sometimes I wonder why I'm doing this, as subclassing a control like this was so easy to do in VFP.[/quote]&lt;/P&gt;&lt;P&gt;As a former VFP developer...it is actually MUCH easier in .NET once you understand the structure of .NET.&amp;nbsp; Greg's sample is spot on...just create a class, then inherit whatever base class that you would like.&amp;nbsp; You can then override base functionality (which is much better then VFP ever was in this area, especially as it relates to events).&amp;nbsp; For example, if I inherit a TextBox and want to change the logic (or add to) of the TextChanged event I could do this:&lt;/P&gt;&lt;P&gt;[codesnippet]Public Class MyTextBox&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits MicroFour.StrataFrame.UI.Windows.Forms.TextBox&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Sub OnTextChanged(ByVal sender As Object, ByVal e As EventArgs)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.OnTextChanged(sender, e)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Add your logic here (or above the base if that is what your require....You can also skip the base logic altogether&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '&amp;nbsp;&amp;nbsp;&amp;nbsp; if that is in fact what you are trying to accomplish.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;BR&gt;End Class[/codesnippet]</description><pubDate>Tue, 29 Jan 2008 09:14:18 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13807.aspx</link><description>You just create a class that is named whatever you like and inherit that class from the control you are sub classing:&lt;br&gt;
&lt;br&gt;
[codesnippet]' VB&lt;br&gt;
Public Class MyTextbox&lt;br&gt;
   Inherits Microfour.StrataFrame.UI.Windows.Forms.Textbox&lt;br&gt;
  ' code...&lt;br&gt;
End Class&lt;br&gt;
&lt;br&gt;
// C#&lt;br&gt;
class MyTextbox : Microfour.StrataFrame.UI.Windows.Forms.TextBox {&lt;br&gt;
  // code...&lt;br&gt;
}[/codesnippet]&lt;br&gt;
&lt;br&gt;
This will then available in the toolbox under the project you put it in (each project that has controls, user controls or components will be a heading in the toolbox).</description><pubDate>Mon, 28 Jan 2008 20:49:11 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13802.aspx</link><description>[quote][b]Ben Chase (01/11/2008)[/b][hr]You'll want to create your own property on the TextBox, say "Value" or "MyText" (something other than Text since it's already taken).&amp;nbsp; Make that property a DateTime property and that property will then be used for your binding (so, bind the business object to that property, not the Text property.&amp;nbsp; &lt;P&gt;In the Get of that property, if the Text is empty, then return 1/1/1800, if the text has a date, then use DateTime.Parse() to get the DateTime value from the Text and return it.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Then, in the Set of the property, if the&amp;nbsp;value is 1/1/1800, set the text to String.Empty.&amp;nbsp; Otherwise, set the Text to value.ToString("MM/dd/yyyy") (where the MM/dd/yyyy is the format you want the dates to appear in).&amp;nbsp; &lt;/P&gt;&lt;P&gt;Luckally, WebForms binding is much simpler than WinForms binding, so you won't have to worry about creating all of those changed and changing events to get the data to bind properly.[/quote]&lt;P&gt;Ok, I know this may rather basic, but I can't figure out how to easily subclass the control to do this.&amp;nbsp; Sometimes I wonder why I'm doing this, as subclassing a control like this was so easy to do in VFP.&amp;nbsp; Do I actually need to create a composite control in it's own assembly to be able to do this?&amp;nbsp; I just want to create a user control and be done, but I can't find any references to how to do this and be able to actually use the control like a normal control.</description><pubDate>Mon, 28 Jan 2008 20:29:54 GMT</pubDate><dc:creator>Cyrus Welch</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13391.aspx</link><description>Got it, thanks!</description><pubDate>Fri, 11 Jan 2008 15:46:00 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13368.aspx</link><description>Ah, for WinForms, when you add a bindable property, you also have to add a "Changed" event that corresponds to the bindable property and it has to have the same signature as EventHandler:&lt;/P&gt;&lt;P&gt;Public Event MyTextChanged As System.EventHandler '-- Your property is named "MyText"&lt;/P&gt;&lt;P&gt;You then raise this event when the property changes so that the binding knows to copy the new data back to the data source.&amp;nbsp; The "Changing" event isn't needed by the binding, but sometimes it's nice to have; I would only add it when you need it.</description><pubDate>Fri, 11 Jan 2008 13:03:06 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13365.aspx</link><description>So, in WinForms, you'd also need to add the changing/changed events to get this to work. Anything else to get to work with a WinForms control?</description><pubDate>Fri, 11 Jan 2008 11:18:25 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13355.aspx</link><description>You'll want to create your own property on the TextBox, say "Value" or "MyText" (something other than Text since it's already taken).&amp;nbsp; Make that property a DateTime property and that property will then be used for your binding (so, bind the business object to that property, not the Text property.&amp;nbsp; &lt;/P&gt;&lt;P&gt;In the Get of that property, if the Text is empty, then return 1/1/1800, if the text has a date, then use DateTime.Parse() to get the DateTime value from the Text and return it.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Then, in the Set of the property, if the&amp;nbsp;value is 1/1/1800, set the text to String.Empty.&amp;nbsp; Otherwise, set the Text to value.ToString("MM/dd/yyyy") (where the MM/dd/yyyy is the format you want the dates to appear in).&amp;nbsp; &lt;/P&gt;&lt;P&gt;Luckally, WebForms binding is much simpler than WinForms binding, so you won't have to worry about creating all of those changed and changing events to get the data to bind properly.</description><pubDate>Fri, 11 Jan 2008 08:28:08 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13336.aspx</link><description>[quote][b]Greg McGuffey (01/04/2008)[/b][hr]Ben,&lt;BR&gt;&lt;BR&gt;What event should you handle (override) in the inherited textbox to handle this issue?[/quote]&lt;/P&gt;&lt;P&gt;Yeah, what he said!&amp;nbsp; I'm willing to do that, but I do need to know which event would be best to do this.&amp;nbsp; I can't have the users seeing the 1/1/1800 value.&amp;nbsp; I know it may take a little more work to handle the situation for the .net gridview which we use because we get paging and such.&lt;/P&gt;&lt;P&gt;I guess what your saying is that the value involved both ways must be a valid date or there are problems?&amp;nbsp; I can live with that I guess as long as I can figure out how to inherit the textbox and change it both ways on the fly.</description><pubDate>Wed, 09 Jan 2008 14:49:01 GMT</pubDate><dc:creator>Cyrus Welch</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13252.aspx</link><description>Ben,&lt;br&gt;
&lt;br&gt;
What event should you handle (override) in the inherited textbox to handle this issue?</description><pubDate>Fri, 04 Jan 2008 12:00:12 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13240.aspx</link><description>Since a DBNull.Value cannot be cast to a DataTime, you must return an alternate date through the property.&amp;nbsp; If you are binding the value to a textbox or displaying it in a listview, then that alternate date is going to display.&amp;nbsp; In order for the alternate date to not display within a textbox, you will need to create your own inherited textbox and change the display when the alternate value is returned.&amp;nbsp; For the value within a listview, you will need to change the column displaying the value to PopulatedThroughEvent rather than using FormattedString; this will allow you to programmatically set the value for the column through the RowPopulating event of the list view.</description><pubDate>Fri, 04 Jan 2008 08:45:05 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Null Dates in Webforms, How?</title><link>http://forum.strataframe.net/FindPost13232.aspx</link><description>Hi Cyrus,&lt;/P&gt;&lt;P&gt;You may have already done this but, if not, try a&amp;nbsp;search for "null date" in all forum posts. From memory this has come up quite a number of time in the past - maybe the answer you want is in the archives.&lt;/P&gt;&lt;P&gt;Cheers, Peter</description><pubDate>Thu, 03 Jan 2008 21:28:25 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item></channel></rss>