This is a migrated thread and some comments may be shown as answers.

values lost when using back button

4 Answers 102 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 08 Nov 2012, 12:23 AM
Hi,

I have a page with a few radcombo boxes and raddateinputs.

On the initial load of the page (when ispostBack is false) I set the initial value of a couple of the raddateinputs.

I select the combo box values and the raddate values and do a Response.redirect in the code behind for the submit button passing the values of the controls  to a new page in the querystring.  The new page functions fine.  from the new page i hit the back button.  the values I picked in the Combo boxes and raddateinputs appear in the respective controls UNTIL I actually click in each one of them and they revert immediately to the default values.  I set a breakpoint in page-load and it is not firing so the cached copy is being loaded.  why aren't the values staying with the controls?

If I don't click in them and submit the page again the values passed through are the default values rather than the values that are actually vivsible in the page.  

I thought it was an ajax issue, but removed the ajax manager from the page and still have them same problem.  I tried setting viewstate on the controls and the same issue arises.

Thanks,

Jonathan

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 08 Nov 2012, 07:17 AM
Hi Jonathan,

You can add a hidden field to the page which will hold the selected value of the combobox and select the appropriate combo item on pageLoad as follows.

JS:
<script type="text/javascript">
 function pageLoad()
 {
  var savedValue = $get("RadComboBox1Value").value;
  var combo = $find('<%= RadComboBox1.ClientID %>');
  if (savedValue != "" && combo.findItemByValue(savedValue))
  {
   combo.findItemByValue(savedValue).select();
  }
 }
 function onSelectedIndexChanged(sender, eventArgs)
 {
  $get("RadComboBox1Value").value = eventArgs.get_item().get_value();
 }
</script>

Thanks,
Princy.
0
Jonathan
Top achievements
Rank 1
answered on 08 Nov 2012, 07:43 AM
Hi Princy,

This behaviour seems non-standard.  The controls should keep their values.  If I use a regular asp:dropdownlist I don't have this issue.  Why do telerik controld lose their values.

Also, if I am forced to do this, how do I access the date part fo a rad date picker client side and store its value and then set it?

thanks
Jonathan
0
Princy
Top achievements
Rank 1
answered on 09 Nov 2012, 06:15 AM
Hi Jonathan,

You can set the value of RadDatePicker in clientside as follows.

JS:
<script type="text/javascript">
  function pageLoad()
  {
   var savedValue = $get("RadDatePicker1Value").value;
  if (savedValue != "")
  {
   dateVar = new Date(savedValue);
   var datepicker = $find("<%= RadDatePicker1.ClientID %>");
   datepicker.set_selectedDate(dateVar);
  }
 }
 
function OnDateSelected(sender, args)
{
  $get("RadDatePicker1Value").value = args.get_newValue();
}
</script>

Thanks,
Princy.
0
Jonathan
Top achievements
Rank 1
answered on 13 Nov 2012, 08:40 PM
ok thanks I escalated to a support ticket.
Tags
General Discussions
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Jonathan
Top achievements
Rank 1
Share this question
or