Asked by:
mobile:textbox in ASP .NET 2.0 and emptyok

Question
-
User641687622 posted
Been tearing my hair out over one of those 'simple problems'!
I have written a fairly complex application that renders a menu of links, followed by a textbox where you can type in something to search for.
On an xHTML capable device everything is fine, same with stuff where it renders in HTML. But on some WML 1.1 devices, the links don't go anywhere, as the input (what the textbox renders as) expects something in it before it will allow you to leave the deck. Oddly enough on some devices ASP .NET generates a new deck to put the control in, to get around this, but not on all devices.
I dug around and found that there's an attribute of 'input' inWML called 'emptyok'. By default it's false, hence my problem.
So I set out to add this to my textbox. With a regular asp:textbox you could just do
myTextBox.Attributes.add("emptyok", "true")
But you can't do this with mobile controls.
For the moment my work around is to design the form with a different deck for the input, but this is a bit of hack, unless you add
Next I tried a user control, with a regular asp:textinput and some device filters which figured out if they could add WML only attributes. The only problem was that getting the actual value back from an input control in WML is not like a normal page and I got bogged down in writting my own <do> and <go> and <postfield> stuff, which I have given up for the moment.
So, any other ideas? Is there some clever way to overide rendering in the WML version and sneak emptyOK in there as well? This is quite fustrating, as having emptyok in mobile:textbox would have solved this one. Still, despite this MMIT is better than dealing directly with WML.
Dylan
Friday, October 14, 2005 10:00 AM
All replies
-
User-1188861688 posted
Hi Dylan
Just a shot, but to assign custom attributes to mobilecontrols you have to explicitly allow them first. This is done in web.config, e.g:
<system.web>
...
<mobileControls allowCustomAttributes="true" />
...
</system.web>
Perhaps this will resolve it.
Regards
/Mike
Friday, November 4, 2005 11:32 PM -
User-2115551320 posted
I had the same problem and solved by modifying the adapter source code (MIT)
FileName: WmlMobileTextWriter.cs
Function: RenderTextBox
Code added: WriteAttribute("emptyok", "true");
Nicholas
Monday, December 19, 2005 2:37 AM -
User-598002374 posted
how did you get the framework to use your adaptor source? _ronsonTuesday, January 31, 2006 4:59 AM -
User-2115551320 posted
Just put your adapter dll in the bin-folder and in your web.config add (change to xhtml)
<mobileControls cookielessDataDictionaryType="System.Web.Mobile.CookielessData"/>
<device name="HtmlDeviceAdapters-ShippedSource"
predicateClass="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlPageAdapter,System.Web.UI.MobileControls.ShippedAdapterSource" predicateMethod="DeviceQualifies" pageAdapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlPageAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"> <control name="System.Web.UI.MobileControls.Panel" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlPanelAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.Form" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlFormAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.TextBox" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlTextBoxAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.Label" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlLabelAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.LiteralText" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlLiteralTextAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.Link" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlLinkAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.Command" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlCommandAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.PhoneCall" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlPhoneCallAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.List" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlListAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.SelectionList" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlSelectionListAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.ObjectList" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlObjectListAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.Image" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlImageAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.BaseValidator" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlValidatorAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.ValidationSummary" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlValidationSummaryAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.Calendar" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlCalendarAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.TextView" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlTextViewAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> <control name="System.Web.UI.MobileControls.MobileControl" adapter="System.Web.UI.MobileControls.ShippedAdapterSource.HtmlControlAdapter,System.Web.UI.MobileControls.ShippedAdapterSource"/> </device> </mobileControls>Nicholas
Wednesday, February 1, 2006 2:20 AM