开发者

How to add and fire events of dropdown list created dynamically in mvc3

开发者 https://www.devze.com 2023-03-12 15:27 出处:网络
I have an mvc3 application.In which I am using razor view..I have some problems related to dynamically hiding and unhiding the controls also creating controls dynamically.

I have an mvc3 application.In which I am using razor view..I have some problems related to dynamically hiding and unhiding the controls also creating controls dynamically.

Problems:

  1. I want to dynamically hide or unhide some div tag according to value of some form control without using java script. ex: Like I have a dropdown list to select the value..If the selected value is "other" then need to show a text box (which is hidden initially).

  2. I want to create more than 1 dropdown list dynamically on the basis of value of a dropdown list on a form and also want to show some data on selecting of any dropdown item created dynamically. I have a dropdown list "List1" which has 2 values ex value1 and value2..If we select value1 from dropdown then how can we create more than 1 dropwdown list dynamically. If we select any value from the dynamically created dropdown list then how can I show some information related to it on the page.

Is there any solution to perform above operations without using custom javascript or can we use unobstrusive javascript?

Th开发者_StackOverflow社区anks in Advance..


  1. For hide/unhide div tags or any controls, you need to use set style as hidden. but you need to use javascript to setting style at client side.

  2. In MVC, its not possible to create controls at runtime. we can hide/show already controls based on your selection.

0

精彩评论

暂无评论...
验证码 换一张
取 消