I would like to direct a user to a page within an app using a field value from a model. The model is loaded into a grid and the user makes a selection to navigate to a page within the app based on images displayed in the grid cells.
I am thinking to use the app.showPage(app.pages.Page) for the onClick event and passing in the page the user should be directed from the model as a parameter such as widget.datasource.item.PageName.
Can you suggest how the name of the page could be passed in from the datasource as as variable to the onClick event accomplish this navigation?
Will appreciate any help!
Lets say you are storing your page names in your datasource under a field PageName (string field) such as YourPageName1, YourPageName2, etc. Then for your onClick event all you would need is:
app.showPage(app.pages[widget.datasource.item.PageName]);
Related
Using a ViewModel in a View in ASP.NET MVC app.
Have a dropdownlist on page and based on user selection, I need to show/hide a section. For certain options in DDL, the section is visible and for certain options the section is hidden.
For other similar features, I was able to create a property in ViewModel and call it in the View.
But in this current case, I need to pass the value of selection option and then find if it is one that needs the section hidden/visible.
Should I create a method in viewmodel and call method in view and pass the parameter of selected value? If so, then how to do that?
if that's not the way to do it then what's the recommended approach?
Thanks
You can bind a JavaScript/Jquery function to the dropdown list's onchange event. Inside the function you can write code to show/hide sections based on the selected value in dropdown list.
Further more, if you need to call a back end service to do any validations or retrieve data, you can use Ajax techniques.
I want my popup to display user data (possibly with edit/delete options). I've handle following function to the RowDBclick:
popupControl.Show(grid.GetSelectedKeysOnPage());
And in the popupControl I've set Popup Element Id to grid which is my ClientInstanceName of the GridView. The popup appears but with no data. What do I do wrong? How to display user data of the clicked row id? If I set Choose data source in Popup task panel to my db ConnectionString, the popup doesn't appear.
There is no client-side Show method for ASPxPopupControl that accepts an array of values. ASPxClientPopupControlBase.Show Method. You need to perform a callback on the PopupControl (PerformCallback), populate its controls with required values obtained from the grid in the server-side WindowCallback event handler. After this show the popup.
Lets say I have three DropDownList controls in a web user control and they depend on each other.
Categories
Brands
Products
Explanation:
After I choose a category from Categories dropdown list, related brands are loaded in Brands DropDownList and same happens when I choose specific brand and they are all located in a web user control since I am using it too much on different pages, I don't want to copy and paste the same code on all the pages.
Problem: The pages can contain a GridView and DataSource control which needs an additional Where parameter to fetch all the data needed in and that parameter could depend on selected product within the Products DropDownList control.
Question: So how can I get that Selected Product Value from Products DropDownList to bind it to SQLDataSource or any other DataSource control.
My Thoughts: I belive I can solve this problem in the ways following.
I can use static variable which is updated once Products selected. That field variable could be public so everyone can reach it
Selected Products DropDownList can create a QueryString Field for me to grap the selected value.
In the same way, the dropdownlist can create a Session variable on the fly and I can fetch the value
It can create a hidden field maybe.
But: Well those are some of my thoughts but I found them so naive to implement. I need something elegant and satisfying to solve this problem. It should be something like a gateway from the Web User Control to outside world.
Maybe a separate class or a Property can help me in the gateway solution.
Anyways, I am waiting for your answers.
If I'm understanding the question correctly:
You can add a property to the user control that exposes the products DDL selected value.
You can also add and raise an event from the user control that fires when the products DDL selected value changes. Creating a custom event argument that contains the product value, allows it to get passed directly to the event handler.
Then your pages can handle the event raised by the user control, have the product value, and bind the grid.
You could bind the DropDownList.SelectedIndexChanged events to the same function, and test the SelectedValue properties of each DropDownList. If their SelectedValues are valid, bind the grid to your DataSource.
I've done this in the past when I needed users to input a certain amount of data before I could query the database. I set the Hidden property on my GridView if the DropDownLists weren't valid, and reset it when they were properly bound.
I have on server control(dropdown) and One button.user can select some values in dropdown and click button.I have to show a pop-up.In this pop-up I have show data based upon value selected in dropdown.How to access a dropdown in codebehind of pop-up screen.I am loading a .aspx in pop-up using javascript.
Why not just pass the selected value of the dropdownlist as a querystring parameter to the popup page?
That's the way i'd do it.
If you dont want to do it that way, you can access the parent window by using window.opener.document.
So something like:
window.opener.document.getElementById('yourDDLId').value;
Still i'd recommend passing through as querystring param. Simple and easy.
I have an ASP.NET page where I am dynamically building LinkButton and TextBox elements. These elements are being built during the OnInit event of the page. The user can then perform an action that changes the values of these elements. The values of these elements are changed via JavaScript. When the user clicks a button, a server-side event is fired. This event parses the value in each control. I have noticed that the value for the TextBox is correct, but the value for the LinkButton is not.
Can only certain types of controls in ASP.NET be dynamically generated and have their values retrieved on the server side?
Thank you.
You can't get value of link button at server side. You can only get form elements' values at server side.
If you want to pass more values to server side, you can use hidden input elements.
No, generally you can create whatever element you like, given you create it inside the OnInit event or if you add the INamingContainer (marker) interface, you should override the CreateChildControls() method and create your elements in there.
But what do you mean by changing the value of the LinkButton via JavaScript? What exactly do you change on the LinkButton?? Could you provide more details?
Ensure that the "runat=server" property is set for each form element you want to retrieve via server code, and that you have an ID associated with each.
The textbox is working because value of the textbox is actually sent in the postback. But the linkbutton doesn't send anything back to the server. If you need to send something back that gets changed on the client, you'd need to set a hidden field and then modify your linkbutton using that value.