DNN 5 viewstate - viewstate

HI,
I'm working on DotNetNuke 5 module that basically consists of three pages; step 1, step2 and step3.
On Step 1 I'm showing a GridView with a CheckBox column and button that should navigate the user to Step 2.
In Step 2, I'm showing a GridView as well that shows the items that have been selected in Step 1.
My questions are:
What is the best way to pass my selection from Step 1 to Step 2?
ViewState? Url-parameters?
I tried in Step 1: ViewState["SelectedItems"] = string.Join(",", list.ToArray());
IN step 2: I did:
var items = (string)ViewState["SelectedItems"];
And I found out items contains empty string. Is ViewState supported by DNN5?
The built-in ASP.Net wizard control doesn't offer enough flexibility for customizing it's look-and-feel and therefore it's not being used. Does DotNetNuke perhaps offers an alternative for ASP.NET WizardControl?
Thanks!

ViewState is definitely supported in DNN. However, if you've actually setup different pages for each step, ViewState isn't going to be available (it only persists across postbacks).
If you'd prefer to keep a three page scheme, using URL parameters if probably the easiest. If that's not palatable, then you'd have to store the info in either a cookie, in the database, or in the Session.
If you want to combine your steps into one control and use postbacks instead of redirection, then you can use ViewState. I don't think DNN exposes its wizard framework controls, but you can use a MultiView control or something similar to switch between the different steps more manually.

In my opinion, you will want 1 single .ASCX for your DNN Module, but you will want three panels inside, one for each step. I would call the panels Panel_Step1, Panel_Step2, and Panel_Step3. Steps 2 and 3 will be hidden initially.
Each panel will contain all of the controls and graphics for its respective step in the wizard.
So, when the user clicks the "Next Step" button to proceed from Step 1 to Step 2, your code will hide Panel_Step1 and show Panel_Step2. You will want an init function for Panel_Step2. Let's call it InitStep2().
Inside this InitStep2() function, you will be able to analyze the values and selections that the user made in Step 1 by analyzing the control values direction.
Example: Textbox_Step1_Name.text, DropDown_Step1_State.SelectedValue, etc.
These values are indeed stored in the viewstate.
Doing a wizard in this manner is really no different than doing it using an .ASCX outside of DNN. You have access to the viewstate, session, and more.

Related

Changing ASP Included file and saving choice as a cookie

Ok, so I'm in the process of expanding my knowledge and need a step in the right direction, not necessarily an answer.
I am wanting to create a script for my eCommerce site that lets users choose between grid and list view on product listings pages.
The grid view will be called using an included file called "incgridview.asp" - the list view file is called "inclistview.asp".
Upon the user choosing an option from the drop down specifying which type of view they want, the respective file should be called. So if they select grid view, I need to load the incgridview.asp (list view will be loaded by default).
Once the selection is made, I need it to switch the view without reloading the page, and store a cookie for 7 days that remembers their selection. Of course, they would still have the option to switch back to the other view.
So basically I am switching which file is included upon user selection of the drop down. Im thinking maybe I need to use ajax but not sure. Any help is greatly appreciated. Thanks!
EDIT
Ok, so this is what I am trying to use, on my file that actually includes the grid pages. It is throwing up this error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: '[object]'
/productsviewtest.asp, line 59
Dim listgridcookie
listgridcookie = Response.Cookies("atdviewcookie")("viewoption")
Select Case listgridcookie
Case "list"
print"list view"
Case "grid"
print "grid view"
Case Else
Response.Cookies ("atdviewcookie")("viewoption") = "grid"
Response.Cookies ("atdviewcookie").Expires = DATE + 7
Response.Redirect(Request.RawUrl)
End Select
here is a steps on your page load:
1) Check if cookies exists and what values are there, if it does not exists - create one with default value.
2) Based on value from cookies show div which has been loaded with data from proper include file.
3) When/if selection changes create/re-write cookies with expiration time you desire.
All what you need to build is JavaScript based switch to show one element and hide another.
If you like to use AJAX or JQuery - you can do it this way but for my taste it take away challenges of creating something you can be proud of.
This is based on your " page must not be reloaded upon changing selection" statement.

Load a XAML Layout dynamically based on User interaction

Good day, I am quite new to windows phone and so please bear with me. I have a requirement to load a XAML layout based on what the user chooses. For example, if i have 4 XAML layouts A, B, C, D, when the user chooses C, the respective XAML layout should be loaded and if A is choosen later, that should come up. I can create different XAML layouts and use the OnNavigateTo Method, but i think its not very efficient. Is there a way, i can group the XAML Layouts together so that it can switch between them easily?.. I have heard of using templates, but can't really find any concrete example of how it works. Any help or links will be greatly appreciated. Thank you.
From my understanding you do not need to use templates. Since there are four different actions that have four different views associated with them, there shouldn't really be a problem with having a separate page for each action.
The problem might also be this - how different are the layouts? If data is the only thing that changes across them, you might think about having a view model to bind to and simply change the bindable source.
Bottom line: just use pages, or a single page bound to dynamic data, depending on your scenario.
In my knowledge , I ask you to prefer the UserControls implementation in your UI. You can have A,B,C and D layouts as a separate UserControls and can have those UserControls in the same page. Just make the visibility changes based on the condition that recognize it in the code behind. I think it may help you.
You can solve this in many different ways. If you are not supposed to load the layout on the same page, create 4 separate pages for each view and navigate to correct page.
If you are required to update the current view, you can choose one of the following:
- Place all four layouts into each own Grid and set Visibility="Collapsed" for each one. Then, when you need to show a layout, simply change its Visibility to True.
- Same as above, but use Visual States to add some animations.
- Create 4 user controls and dynamically create the one you need and add it to the current page.
You need to account for several factors here:
- Clean code and clean design.
- Animations and transitions.
- What about Back key? If user is supposed to navigate back to selection screen once he is done, consider navigating to separate pages.
Don't forget the last point, it may be crucial when choosing the right solution.

COLDFUSION CFGRID Datapass with a post

I have a bit of a unique challenge today. I have a client that wants to be able to search for multiple items based on inserts into a cfgrid. Suppose we have the following web form:
A Country selection dropdown
A State Selection dependent AJAX dropdown
A city Selection dependent AJAX dropdown
An ADD Button
----------------------------------------------------
A CFGRID that will populate a row with selections when the user clicks the add button
----------------------------------------------------
And finally, a CLEAR button, and a GO button on the bottom.
The resulting page will then query the database and get some statistics about the cities selected. So, suppose an individual picks USA > Arizona > Scottsdale and USA > Arizona > Flagstaff. The grid below the options will 'save' each selection and reset to their default options, waiting for a user to pick additional options or click on 'GO'.
The resulting page will then generate columns that list some statistics about the communities and highlight the 'best of' between each selected community.
Each time a user selects the ADD button (assuming three criteria are selected) I want the information to be added into a CFGRID that displays the options selected. Then, After the user selects at least one country/city/state option, have all of the data in the CFGRID get passed to another page that does a query from the data selected. In theory, the user could pick as many communities as they want, assuming they are willing to let the database sludge through enough data to get what they want and wait through a 'loading' screen to get it.
I'm having these challenges, in no particular order:
- I have an HTML grid that I must use per client spec (No Java or Flash, must be HTML)
- I have no idea how to get the selected options into the CFGRID. I assume there is some JavaScript I can write that uses some sort of AddRow function to add data into the grid with the add button but cannot seem to find how to it on the interwebs
- After we conquer the above challenge, how do I pass the data from the grid into the results page? I thought about passing one big string or a structure, but I'm not sure how to do that through the URL or posting, nor how to get the data out of the grid. I wonder if I am better off coding some sort of string that gets passed from the options page to the results page with a get method instead of dealing with the stuff in the CFGRID and have the CFGRID serve only as a 'dummy' display container.
- Finally, after the pass is complete, I would need to loop through through the structure and perform a CFQUERY or CFSTOREDPROC on each row of data, then get the statistics I need to display on the results page. I assume this would depend on how I am getting the data from the options selection page to the results page.
THANK YOU ALL!
CFGRID is great to start, but it can be b*tch to customize and extend... Have you tried editable CFGRID with bind? See how far off it is from what you want first. If it turns out to be very far, then you might want to go for a jqGrid and code up some jQuery.
To start, read Using HTML grids and make the cfgrid editable.
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a01.html#WSc3ff6d0ea77859461172e0811cbec22c24-72e0
Once you got that working, look at these provided JS functions that you can use with CFGRID
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS0ef8c004658c1089-6262c847120f1a3b244-8000.html
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSd160b5fdf5100e8f-4439fdac128193edfd6-7f5f.html
If you still demand a bit more, you might need to dig into the underlying ExtJS component. At that point I would rather use jqGrid
I found out that the best way to handle this was by using a SerializeJSON call and a Deserialize JSON call back and forth. By using JavaScript notation we are able to pass a complex JavaScript object (array) between one page and another. This has the value add of not having to worry about sessions timing out and making URLs clickable from one solution to the next.

Handling site wide data in MVC Razor

I've seen this question asked in a couple of places and generally the answer has been "use the ViewBag" which I don't think fits our scenario.
We have a membership site which has common properties (e.g. Account -which contains the user's account settings) and I would like to use that in both the Views and _layout.cshtml (e.g. to allow the user to change the colour scheme).
In the views, we're inheriting from a base view model but how can we get access to this data in the standard pages e.g. About Us etc which don't have any associated view model? I've tried creating a partial view which passes the data through in it's controller but that didn't work
Your main options are:
1. Consider implementing a profile provider - the settings are then available everywhere, use an Action Filter
2. use your own custom context assigned to the current request/user
3. use a base controller/base viewmodel for the pages that don't have them
4. use a global action filter
5. viewdata/session
See some details at:
ASP.NET MVC 3 layout ViewBag data across all child views
if you already have this working and need access in an "About Us" page and don't want another view model (why not?) then an action filter would be the way to go - unless this is a typical aspx page in that case you are left without options 3/4 above.

Alternative function for group inorder to improve the performance in a xfrom

Can we use an alternate function other than group to perform the same action. The scenario I am trying to workout using group is - I have multiple pages in a form and a summary button on the first page which on being clicked should show the summary of all pages.
The logic we tried was using group to club each individual pages by having a form variable which turns true when the summary button is clicked and we check this variables value in all pages and so when the summary button is clicked this condition satisfies and all the pages are displayed.
The Code Snippet
<Xforms:group id="page-1"
ref=".[instance('form')/current-page = '1'
or
instance('form')/summary = 'true']">
Using group fn drastically depreciates the performance. Is there any method to perform the same scenario. Kindly advise.
At this point, hidden groups and hidden cases work differently:
The controls in hidden groups are non-relevant.
The controls in hidden cases are relevant.
As a result, using a switch/case, the server has to do more work to maintain and update the state of controls in hidden cases, but switching to a another case is very fast: it is pretty much just a matter of changing a class in the HTML, as the values of all the controls are already there. With hidden groups, when "switching to another group", the values for the controls in that group are sent by the server to the browser. Updating the values can take a little bit of time, especially if you have a lot of controls, say in a repeat.
It is hard to give a recommendation without really running your code, but if the time taken to do a switch is mostly spent on the browser, you could investigate using the full update mechanism. If the time is mostly spent on the server, then I'd look into XPath analysis. (Note that both features are PE-only.)

Resources