Heinz
Posts: 9
|
Posted: 03/05/2014, 7:24 AM |
|
Hey together
I use the first time the inMotion framework, with c#
I created a record form with several listboxes and filled them by database.
So far, so good.
Now I want to set the selectedValue for one listbox based on a sessionvariable. (Session["UserLogin"])
Without success
I tryed event before show of record form with:
T_WeRep_data is the name of my recordform
Following userlogin is string value only to check function
CreationUser is the name of the listbox
T_WeRep_data.GetControl<InMotion.Web.Controls.MTListBox>("T_WeRep_data_ctl00_CreationUser").SelectedValue = "userlogin";
or
T_WeRep_data.GetControl<InMotion.Web.Controls.MTListBox>("CreationUser").SelectedValue = "userlogin";
I tryed event before show of the listbox with following code:
((MTListBox)sender).SelectedValue = "userlogin";
I tryed also everything what I could find in InMotion documentation.
Additional Info: My recordform is implemented into a tabbedView
Any Idea what I did wrong? / A hint how I could do it better?
Thank you in advance
regards
Heinz
|
 |
 |
eratech
Posts: 513
|
Posted: 03/06/2014, 12:38 AM |
|
Heinz - you might be overthinking it - let CCS do the work for you.
Try adding the 'Retrieve Value for Control' action to the listbox's 'Before Show' event.
You can fill in the Source Type (Session) and the Source Name (the name of the Session variable, probably in quotes)
I've used this in non-InMotion projects many times but I don't have an InMotion project to try it out on at the moment. If you still have problems, I will get an InMotion project going to confirm it works.
Cheers
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
 |
 |
Heinz
Posts: 9
|
Posted: 03/06/2014, 1:24 AM |
|
Hi Eric
Thank you very much for your help.
I tryed what you suggested.
I deleted all events and add the action.
The code was the same like i did manualy:
T_WeRep_data.GetControl<InMotion.Web.Controls.MTListBox>("CreationUser").Value = Session["UserLogin"];
Also, it still does not work...
I tryed also:
1) T_WeRep_data.GetControl<InMotion.Web.Controls.MTListBox>("CreationUser").SelectedValue = Session["UserLogin"].ToString();
2) System.Web.HttpContext.Current.Response.Write("ControlValue:" + T_WeRep_data.GetControl<InMotion.Web.Controls.MTListBox>("CreationUser").SelectedValue);
While debugging the return value of the session is checked and o.k., The return value of the MTListBox is empty.
Then I tryed to debug the MTListBox class.
I figured out, that the value is lost between set and get.
No Iam at the end of my ideas
|
 |
 |
eratech
Posts: 513
|
Posted: 03/06/2014, 4:22 PM |
|
Ok - thanks for trying it - obvious question: if you are setting a listbox of names, the userlogin is one of the items in the listbox right?
I'll fire up my CCS later today and try it myself and get back to you.
Thanks
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
 |
 |
vsuarez
Posts: 8
|
Posted: 03/06/2014, 8:06 PM |
|
You may try using the client side onLoad event of the Page, and set the selected Listbox entry using Javascript:
getMTControl(“form_name.listbox_name”).options[user_index].selected = true;
where user_index is a zero-based index pointing to the listbox entry with the user you want to select.
Hope it helps
|
 |
 |
Heinz
Posts: 9
|
Posted: 03/07/2014, 2:31 AM |
|
Quote vsuarez:
You may try using the client side onLoad event of the Page, and set the selected Listbox entry using Javascript:
getMTControl(“form_name.listbox_name”).options[user_index].selected = true;
where user_index is a zero-based index pointing to the listbox entry with the user you want to select.
Hope it helps
Hi
hmm. could be a solution...
I will give it a try.
Thanks
rgds
Heinz
|
 |
 |
Heinz
Posts: 9
|
Posted: 03/07/2014, 4:04 AM |
|
Hi Eric
The bound column of the listbox is a userid (text) and the text-column is the displayname of the user
Also the type is set correct.
Sample:
userid: "rkst22"
Displayname: "Rieder, Heinz (Departm)"
The userLogin is also: rkst22.
I checked also both sides, if the content is realy the same and that there are also no empty chars in the fields. 
thanks, rgds Heinz
|
 |
 |
Heinz
Posts: 9
|
Posted: 03/07/2014, 4:26 AM |
|
Hi together
shame on me !!
I found the solution.
It did not work, because on one side the value was in capital letters and in the session variable the value was in low letters. This is realy a beginner problem.
I am sorry, but I am sure it will help others to prevent of doing the same.
Thank you for all!
rgds Heinz.

|
 |
 |
eratech
Posts: 513
|
Posted: 03/08/2014, 12:07 AM |
|
Glad you got it working. I set up a test site and got it working, but hadn't tried different capitalisation.
E
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
 |
 |
|