So, basically my problem is that i have a series of tabs on my page, one of the tabs (not the default one) has two drop-down lists, the second drop-down list only populates after an item from the first drop-down list is selected, obviously without putting the autopostback = true value in my drop-down list, they wont automatically populate however adding autopostback = true causes the page to reload and changes tabs back to the primary default tab. Is there any way around this that people know as i don't really want the users having to change back to the correct tab 4 times to fill in a form. Thanks
I think your dropdown is asp:DropDown (server side). I recomend you to use html element and do your staff at front end with jquery,ajax etc. But in your case if you want to update part of the page without using front end tools (jquery-ajax), You should use asp:UpdatePanel for it. Search for it, it is not so complex. Good luck.
Introduction to the UpdatePanel Control
How do I use updatePanel in asp.net without refreshing all page
Related
Sorry if this belongs on SP SE, if so please migrate.
I aplogize in advanced if my terminonlogy is off this is all new to me. I have a Sharepoint I am helping maintain. The Sharepoint has custom code (WSP's) that make up Sharepoint Lists/List items on the Sharepoint, which are created via code (.net C#). From what I'm seeing, in addition to creating the forms for creating new list items and defining the list items, you also set the url for each list item action (namely, when you click the checkbox next to a list item, the ribbon bar has buttons for "view" and "edit" which in theory you're supposed to set to the form page url's for, such as ViewItem.aspx, EditItem.aspx, etc). I can create a different page for viewing the list item and a different page for editing the list item of my custom list, but the problem is that view list item is identitical to edit list item with the exception that in "view list item" all the fields are turned to disabled once they are populated.
It seems extremely redundant to create a copy page of all the exact same logic as the edit page, plus the few extra lines of code to disable the fields once they've been populated. Is there another way (such as somehow altering the querystring generated by Sharepoint so I can add my own flag to indicate that the user is "viewing" the form instead of editing it)? I was able to use the same page for edit and new form because when you edit a list item SP adds the list item "ID" to the querystring paramater, but i dont see a parameter I could key off of to indicate that the form should be opened in "view" mode.
I am working on a project in which on selecting a drop down list item the values from the database should appear in the respective two text boxes.
But, alongside I am placing an image which is actually getting created based on the two values. Now on selecting the next dropdownlist item there is a page refresh and the placed image dissapears.
How to I avoid the page refresh keeping in mind that the fields from the database must get displayed on the page in the two fields on select of drop down list.
Kindly help!
thanks...
In my case, there exists a table in which there are two halfs, the left has text boxes n a button n to the right side of the table the image appears.
If you are using ASP.NET WebForms, you could wrap the controls which you only wants to post back inside an UpdatePanel.
Alternatively, remove AutoPostBack="true" from your DropDownList, and use javascript/jQuery AJAX to perform your database request.
Disable autopostback.
<asp:DropDownList AutoPostBack="false" ... />
Without the slightest piece of code, this will be hard to answer.
To prevent default behavior in javascript, there is this method
e.preventDefault();
Where e is your event.
Your issue is to preserve the values fetched from DB.
The easiest and safest way is to store the values fetched from database into hidden fields. This way when your page postbacks the values persists and you can use them as you wish.
Happy Coding!!!
I know this has been asked, but none of the numerous answers fit with my situation. So I will humbly ask if someone can walk me through this again gently.
Environment: .Net 4 web app using c#, javascript, jquery, sql server, and entity framework.
Question: I need to be able to allow a user to "quick add" a value into a table that is bound to a drop down box without losing values a user has already entered onto current page. I don't care if I have to do a postback or use jquery or use ajax, etc. I need the functionality first - prettiness later ... the scenario is described below if you care to keep reading. With all that being said, I would love for this to be smooth and not "clunky" for the user.
Scenario:
I have a page where the user is able to enter many pieces of information into textboxes, static drop down boxes, and drop down boxes that are bound to other tables that will all get combined and inserted into one table. Well, it never fails, a user could be filling in the page and when they get to one of the table bound drop down boxes - a value is missing or they haven't added something item yet. I would like to add a button or link or something next to that drop down box that would allow the user to "quick add" an item to the table that fills that drop down box and then refresh the drop down box so they can choose that new value from the list ... all while not losing the other data on the screen they already entered.
What I've tried:
-Tried WebMethod option. Currently, this web page calls some custom "bind" methods in the code behind to fill drop down boxes so they are not filled directly from objects from entity framework. So that means using a static method will not work for a solution because part of the static function would need to call the bind method to refresh the drop down box with the newly inserted values.
-Tried PageMethod option. Some of the other samples used Page Method settings, but my site uses master and content pages and the posts seem to state that the page method route was not going to work.
Make sense?
Add an UpdatePanel to the page. The update panel should wrap the drop down to be added, as well as the textbox/button for adding a new entry to that drop down. You would want to have a different UpdatePanel for each dropdown/button pair, if applicable.
When they click the button inside of the update panel you can read the textbox, add an extra item to the drop down, and send an update to the database. (I'd manually add the new value to the drop down rather than updating the database and re-binding, if possible, but it may not be.)
The magic of UpdatePanels will make sure that this is all asynchronous and so doesn't disturb the user working on the page.
I am using a ASP.Net and AJAX web which contain
TabContainer
gridView(grid view generated in run time and make 1 of
the column as the tab page header)
combobox
2 textbox(date fr/to)
button
Problem is.. after the data was retrieved.. everything look find. now i want to fire the tab container event.. autopostback set to true.. once user selected the tabs.. all the things from the page are disappear..(actually i test for other component which is set the autopost to true.. it will make some effect) its seem to be reload without pulling back the existing movement.. what can i do to enhance it? is it anything related to my coding? or setting? or concept was wrong already?
before tab click
after tab is selected
I am creating online booking page.
I got some example page you can see in this link
http://www.parkercorporate.co.uk/webbookercc/OneForm.asp
I need the same behaviour in my site whenever user selects value in pickup dropdown list in the right side I need to change the text values or view.
To do this behaviour how should I write code in ASP.NET and c#.
Thanks
Ranam
First, use an UpdatePanel so you don't see any visual postback.
Second, set the AutoPostBack property on your DropDownList to True.
Third, handle the DropDownList's SelectedIndexChanged event. This will now fire after every change in the DropDownList, because you enabled AutoPostBack.
In the event handler, you can now change the ActiveViewIndex of the MultiView, or show/hide controls, change textboxes, etc.
First, create different blocks (i.e divs) and give ID's to them.
Then, for each value in the dropbox, fill the divs w.r.t it.
Assign "OnChange" event to the dropdown, and in the handler, set visible or invisible to corresponding block.
On the other hand, If you want to do this on client side, I strongly suggest you to use JQuery, to prevent a lot of requests going to server.
Check this out with JQuery:
make visible div on dropdown select in jquery
If you won't fetch values from database, there is nothing complex about this page. Because it just writes hospital if you choose hospital etc. and changes control's visible state.
Even if you think you need db queries when dropdown's selected change event, actually at this page there is no need. Just store db values in hidden controls (like Hospital- for Hospital) and when dropdown selection changes, write hidden's value completely in javascript