[CLOSED] get datefield typed value

  1. #1

    [CLOSED] get datefield typed value

    Is it possible to get the value that was typed in a date field from the text property? for example, if the user types garbage in a date field like "asdf" can i access that, the only properties I see are all date types (SelectedDate, SelectedValue, etc) and if i try to access the text property I get an error about converting a string to a date.
  2. #2

    RE: [CLOSED] get datefield typed value

    Hi alexkay,

    You can get the raw value submitted to the server by requesting the value from the Request.Forms collections.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public void Button1_Click( object sender, DirectEventArgs e )
        {
            X.Msg.Notify("Form Value", this.Request.Form[this.DateField1.ClientID].ToString()).Show();
        }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Button runat="server" Text="Submit" OnDirectClick="Button1_Click" />
    
            <ext:DateField ID="DateField1" runat="server" />
        </form>
    </body>
    </html>
    Hope this helps.

    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] get datefield typed value

    Hi,

    We've added a new property to all Field types, .RawValue.

    The .RawValue property will return the exact value submitted by the form before it's converted to the appropriate Value type.

    For all TextFieldBase type components (TextField, DateField, Combobox, etc) we've also added a new .RawText property.

    The .RawText property will return the .RawValue property as well, but converted to a string type.

    The following sample demonstrates your original sample using the new .RawValue and .RawText properties.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public void Button1_Click( object sender, DirectEventArgs e )
        {
            X.Msg.Notify("Raw DateField", this.DateField1.RawText).Show();
            // X.Msg.Notify("Raw DateField", this.DateField1.RawValue.ToString()).Show();
        }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Button runat="server" Text="Submit" OnDirectClick="Button1_Click" />
    
            <ext:DateField ID="DateField1" runat="server" />
        </form>
    </body>
    </html>
    The .RawValue and RawText properties have been committed to SVN and will be publicly available with the upcoming v1.0 release.

    Hope this helps.

    Geoffrey McGill
    Founder

Similar Threads

  1. MVC Add Controller / Strongly Typed View Bug
    By Doug.Morrow in forum 2.x Help
    Replies: 0
    Last Post: Aug 08, 2012, 10:03 PM
  2. Replies: 1
    Last Post: Jan 09, 2012, 10:55 AM
  3. Replies: 0
    Last Post: Nov 24, 2011, 12:30 PM
  4. Panelgrid work Typed DataSets?
    By carlosmupe in forum 1.x Help
    Replies: 11
    Last Post: Nov 27, 2009, 4:39 PM
  5. Replies: 2
    Last Post: Oct 19, 2008, 11:48 PM

Posting Permissions