XModPro

Keep values in controls after submit

Einar Hjaltason Einar Hjaltason asked May 6, 2014
Active May 9 · Viewed 1725 times
<p>I am building a search project. I have one combobox and two dateinputs and when I submit a form to populate the result I dont want the data in the combobox and dateinputs to disappear.<br>I got this help from Kelly:<br>Since this solution involves a "redirect" back to the same page, your values will disappear. You can re-populate them. In your search for, add a &lt;SelectCommand&gt; tag that grabs those values from the URL or Form&nbsp;&lt;SelectCommand CommandText="SELECT @uid AS UserID"&gt;&nbsp;<br>&lt;Parameter Name="uid" Value='[[Form:userid]]' DataType="Int32" /&gt; (or [[Url:userid]] if you're using the GET RedirectMethod).</p><p>This will pre-fill your search box with the value from the form.</p><p>I tried this and it works fine if I dont use JQuery. If I use JQuery (see code below) all the controls are cleard on submit.</p><p>Here is my form:</p><p>&lt;AddForm Clientname="FerdatorgLeit" Ajax="True"&gt; <br><br>&lt;ScriptBlock BlockType="HeadScript" RegisterOnce="True" ScriptId="KBXM_Theme_ui-pepper-grinder/jquery-ui-1.7.2.custom.css_frmFerdatorgLeit"&gt; <br>&lt;link rel="stylesheet" type="text/css" href="/DesktopModules/XModPro/styles/ui-pepper-grinder/jquery-ui-1.7.2.custom.css" /&gt; <br>&lt;/ScriptBlock&gt; <br><br>&lt;ScriptBlock ScriptId="mask" BlockType="HeadScript"&gt; <br>&lt;script type="text/javascript" src="/js/jquery_maskedinput.js"&gt; &lt;/script&gt; <br>&lt;/ScriptBlock&gt; <br><br>&lt;ControlDataSource Id="dsFerdategund" ConnectionString="MyConnStr" CommandText="SELECT [ID], [TripTypeName] FROM [TripTypes] ORDER BY [TripTypeName] ASC"&gt; <br>&lt;/ControlDataSource&gt; <br><br>&lt;SelectCommand CommandText="SELECT @ID AS ID, @Dagsfra as Dagsfra, @DagsTil as DagsTil"&gt; <br>&lt;Parameter Name="ID" Value='[[Url:ID]]' DataType="Int32" /&gt; <br>&lt;Parameter Name="Dagsfra" Value='[[Url:DagsFra]]' DataType="Int32" /&gt; <br>&lt;Parameter Name="DagsTil" Value='[[Url:DagsTil]]' DataType="Int32" /&gt; <br>&lt;/SelectCommand&gt;</p><p><br>&lt;div&gt; <br>&lt;Label For="ddlFerdategund" Text="Ferðategund"&gt; &lt;/Label&gt; <br>&lt;/div&gt; <br>&lt;div&gt; <br>&lt;DropDownList Id="ddlFerdategund" DataField="ID" DataSourceId="dsFerdategund" DataTextField="TripTypeName" DataValueField="ID" AppendDataBoundItems="True"&gt; <br>&lt;/DropDownList&gt; <br>&lt;/div&gt; <br>&lt;div&gt; <br>&lt;Label For="DagsFra" Text="Dags frá"&gt; &lt;/Label&gt; <br>&lt;/div&gt; <br>&lt;div&gt; <br>&lt;DateInput Id="DagsFra" DataField="Dagsfra" DataType="Date" Nullable="True" width="150px"/&gt; <br>&lt;/div&gt; <br>&lt;div&gt; <br>&lt;Label For="DagsTil" Text="Dags til"&gt; &lt;/Label&gt; <br>&lt;/div&gt; <br>&lt;div&gt; <br>&lt;DateInput Id="DagsTil" DataField="DagsTil" DataType="Date" Nullable="True" width="150px"/&gt; <br>&lt;/div&gt; <br>&lt;/br&gt; <br><br>&lt;AddButton Text="Leita" Redirect="/Heim/Ferdatorg.aspx?iTripType=[[ID]]&DagsFra=[[DagsFra]]&DagsTil=[[DagsTil]]" RedirectMethod="GET" /&gt;</p><p><br>&lt;jQueryReady&gt; <br>$("#" + FerdatorgLeit.DagsFra).datepicker({ <br>dateFormat: 'dd.mm.yy'} <br>); <br>&lt;/jQueryReady&gt; <br><br>&lt;jQueryReady&gt; <br>$("#" + FerdatorgLeit.DagsTil).datepicker({ <br>dateFormat: 'dd.mm.yy'} <br>); <br>&lt;/jQueryReady&gt; <br><br>&lt;jQueryReady&gt; <br>$("#" + FerdatorgLeit.DagsFra).mask("99.99.9999"); <br>&lt;/jQueryReady&gt;</p><p>&lt;jQueryReady&gt; <br>$("#" + FerdatorgLeit.DagsTil).mask("99.99.9999"); <br>&lt;/jQueryReady&gt;</p><p>&lt;/AddForm&gt;</p>

6 Answers

Loading answers...