0

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

Reece Hewitson
  • 75
  • 1
  • 11
  • There are many ways to load the dropdown without postback like using jQuery ajax but easy and quick I can think of now is using Asp.net update panel, https://msdn.microsoft.com/en-us/library/bb399001.aspx – Adil Mar 01 '17 at 10:09
  • use updatepanel and – Singh Kailash Mar 01 '17 at 10:18

1 Answers1

2

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

Community
  • 1
  • 1
Flardryn
  • 457
  • 1
  • 10
  • 25
  • You were faster than me. And I also think that in this case asp:UpdatePanel is the easiest to maintain / develop. Javascript + Ajax here will just put a lot of code on your page definition and that's not MVC friendly. – Lostblue Mar 01 '17 at 10:19
  • 1
    Update panel uses ajax underneath, in your answer "you want to update part of the page without using ajax" you are probably referring to jQuery ajax. – Adil Mar 01 '17 at 10:22
  • I think he is not developing MVC. You might right about a lot of code, but it is the right way to do it i think. Anyway, he'll learn using ajax and will notice that he should give up asp tools someday :) And you are right. In this case using update panel easiest/fastest way for him. Thanks for comment, have a nice day :) – Flardryn Mar 01 '17 at 10:25
  • @Adil Yes you are right :) i meant that actually, but i don't want to confuse him. – Flardryn Mar 01 '17 at 10:27
  • Its batter to make it clear for future reader of the post as he already understood and accepted the answer. – Adil Mar 01 '17 at 10:31
  • @FurkanAyık So How would one go about using jQuery ajax to do this instead of an update panel? if its the best way of doing it then i want to learn how to! :) and no, i don't believe im using MVC – Reece Hewitson Mar 01 '17 at 10:53
  • @ReeceHewitson I know u are not using MVC :) (If you are going to be developer with asp.Net you should/will learn MVC somehow in future.) But for now, use update panel for this kind job but try to learn jquery-ajax. Try small project for posting data to front-end with ajax. Learn basic ajax post syntax. Create modal panel and get a text from there to c# without using asp:button and insert them to database for example. You will learn with practice and a lot of search. Good luck :) – Flardryn Mar 01 '17 at 11:00
  • Okay, thanks for all the help, i'll have a look at learning it! – Reece Hewitson Mar 01 '17 at 11:31