The above is concept of a search interface I want to build in ASP.net MVC. when user clicks on the '+' button, it should create a row text filters or date filters. Does jQuery offer me this flexibility or are there any such UI frameworks which would help me achieve this? There is a search button, not shown, which when clicked should post back and obtain results and display the results
It sounds like you want to create dynamic form. Just use the Jquery .append to add new elements to your form.
$("#myform").append("<input type='text' name='textfield'>")
A little difficult to visualise what you are talking about as it doesn't show in the question.
But if I understand your question then you want to click on a button and show some filter fields right?
This is do-able not only in jQuery but in just standard javascript. All you need to do is unhide the filter elements.
jQuery will give you a nice way to scroll it open though and then you could do a partial post back and just return the results or partial view.
$("#divFilters").slideDown(300);
The code above will open your div.
Or you could jQuery a partial postback, return RenderPartial from your controller and replace the html in a div somewhere. The RenderPartail would be a partial view with your filters in it. Easier to extend at a later date too I'd have thought.
Is this what you were after?
Related
Am working on Ektron 9.I have created an ektron html form with n number of fields.
Suppose i have a radio button list(Choice Field) following a text field.My choice radio button list has
two values Yes and No and the end user select one of those values.
I need to make the following text field required if the user select Yes in the choice radio button list.If selected No no need to make the text field required.
Is there any way to achieve the same by ektron custom validation?i have tried that but when am checking the fields the choice field not listing in the the insert field part of validation tab.
Is anything wrong with me ,if not anyone suggest a solution for this?
Custom validation like you describe is not possible with standard Ektron HTML forms. Your best bet would be to create an ASPX web form to achieve what you need.
There is the possibility of creating the HTML form, displaying it on an ASPX page and then adding your own custom javascript. However this is error prone as the HTML form and JS are very closely tied together. You are better off using an ASPX web form, and not an Ektron HTML form for this.
I am working on a project which has a requirement to build "pages" on the fly. A page can consist of various controls like textboxes, checkbox etc. Currently when the user wants to add a new textbox I make a ajax request and render partial view and return the HTML and show it on client side. This works but I also want to handle the data properly when these dynamic controls are filled up by user. In a way if I am not wrong I need to be able to make array of HTML controls. Now if we give static List to our view and generate textboxes using Html.TextboxFor we see that the name generated is something:
[0].FruitName
[1].FruitName
[2].FruitName
How do I handle this index part when making a Jquery Ajax request so that I always get the correct indexes and render it on client.
If anybody has any better solution than making ajax request then also please let me know. I need to handle the dynamic rendering of HTML controls and also access their values properly when posted back to server.
Take a look at Non-Sequential Indices at http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx.
He introduced a helper method to generate it as well.
Also, I think you can just pass an index with your ajax call which then gets passed from Controller to your partial view and use it to generate a proper indexed TextBox.
Update:
I've asked a very similar question at Submit javascript dynamically added elements to controller method like Stackoverflow
I would like to change the listview template on a button click event. for example if your in edittemplate i would like to switch to ItemTemplate.
i am trying to do this because im writing my own custom update function for the list view. so after i successfully update the row, it doesn't switch back to the default view.
Rgds
Adrian
Adrian,
As you have tagged this as an asp.net question I would direct your attention to jquery (jquery.com). If you use a vanilla template (wrapping your elements in simple "div" tags) and use the jquery tools to do addClass/removeClass and toggleClass and apply various css styles to achieve the visual effect you desire you should be able to land just were you wish.
Using page methods you can leverage your custom update on a partial postback from jquery and reduce the server impact.
If you would rather do this server side you are probable looking to leverage the item databound event to set your template.
A more complete answer would require more information about what you are trying to accomplish.
Cheers,
CEC
I'm working on a asp.net forms web application where I've got advanced search form with grid listing results below. Grid is sortable and pageable. Grid is listing products.
I've got two requirements :
1) make the url remember the advanced search form state so search results page can be bookmarked etc.
2) on the product details page there is a back button that should take the user to the advanced search page with the same settings in the form and same grid state.
I have implemented a workaround to above two problems but I don't think my solution is very clean and I'd like to hear better ideas. My workaround is as follows :
1) I iterate through form fields and I put values into the querystring after the hash. So when the page is loaded it gets the values from url if available.
2) when user clicks a link to product details page from the grid I use javascript to create a cookie with url to advanced search page so when rendering the product details page I know the url for the back button.
I'd like to achieve above functionality in cleaner way.
Thanks,
M
You could try setting the search page form action to GET. This will put everthing in the query string for you, enabling the bookmarking and the back button.
I would like to move items from one list to another on a page, and I'm pretty flexible about what type of a list it is. What's the best way to do that? ASP.NET Ajax? jQuery? Anything else?
There's a nice tutorial on CodeProject that covers dragging with ASP.NET and jQuery:
http://www.codeproject.com/KB/webforms/JQueryPersistantDragDrop.aspx
if you want to do this and PostBack instead of using AJAX to update your data based on from fields you'll need to get creative about what types of controls you use. Page validation will complain about ASP controls like dropdownlists, listboxes, etc. if they contain selected items that weren't in the list when it was rendered.
Better to use AJAX to send back your updates or use HTML controls like unordered lists or select added via javascript and stuff the selected data in another control that doesn't complain (hiddenfield) on PostBack. The alternative is turning off page validation and I don't think that's a good idea.
You can also might look at YUI Library, I'd say it implements Drag & Drop in a very simple and flexible way:
http://yuilibrary.com/yui/docs/dd/
There are a lot of examples etc...