I need to know how to handle the following scenario in Classical ASP. Please assist me with some sample as I am new to classical ASP
By default a dropdown control should be hidden
If Checkbox.value = Yes Then
Show the dropdown control with values
Else
Hide the dropdown control
End if
Regards,
It's actually quite simple - if your checkbox has the name attribute mycheckbox then you could use something like this
<% If Request.Form("mycheckbox") = "Yes" then %>
<select name="mydropdown">
<option value="1">Value 1</option>
<option value="2">Value 2</option>
<option value="3">Value 3</option>
</select>
<% End If %>
What you need to understand is that Classic ASP is server side - which means that the code is executed on the server rather than the browser. This means that in order to get your select dropdown to appear you'll need to post a form to the server and reload the page. If you want your dropdown to appear as soon as the checkbox is clicked then you should be looking for a client side solution with CSS and JavaScript.
Related
I have a dropdownlist with data being bound dynamically this way at Page_Load:
<asp:DropDownList ID="ddlSet" DataTextField="Title" DataValueField="PKSetId" runat="server"
AppendDataBoundItems="true" ng-model="SetId"></asp:DropDownList>
The rendered html is :
<select id="cpContent_ddlSet" ng-model="SetId">
<option value="? undefined:undefined ?"></option>
<option value="3">Test3</option>
</select>
The option Test3 should be selected by default when the page loads, but this isn't happening. I would have set $scope.SetId=3, but don't know this value before hand.
I see similar questions here but the dropdownlists are data bound the angular way, where you can easily set the selected item from $scope.
How to tackle this.
Either you build a server side ASP application or you build a client side Angular application, but don't mix the 2 technologies.
Let Angular do the whole frontend logic and rendering and the ASP will just provide the REST services.
See Angulars Select for an example how to preselect a dropdown value.
You cannot do this in this way.
I suggest to add option at first place with such as:
<option value="" disabled ng-selected> Make your choice:
I am currently working on a project for a big company and they want me to change their website into a multilingual website with as little refactoring of code as possible. They currently have the following setup for a dropdown list:
<select id="selectStatus" runat="server" title="Select Status" class="standardValue" clientidmode="Static">
<option value="optionValue">
selected="selected">TEXT TEXT TEXT TEXT</option>
<option value="Completed">TEXT TEXT TEXT TEXT</option>
<option value="">TEXT TEXT TEXT TEXT</option>
</select>
I was wanting to replace the text as a referance eg.
<option value="Completed"><%= LanguageResources.CommonStrings.ALERT_HDR_ACCOUNTNO %></option>
But this wont work because it wont let me insert a "code block" as the text attribute, is there any other way of doing this?
Thanks in advance, James.
Why dont you set up a language master table and bind your dropdownlist with it & Use asp:Dropdownlist instead of select.
OR
Simply,
List<string> s = new List<String>();
s.Add(LanguageResources.CommonStrings.ALERT_HDR_ACCOUNTNO);
s.Add(LanguageResources.CommonStrings.ALERT_HDR_ACC);
s.Add(LanguageResources.CommonStrings.ALERT_HDR_ACCOUNT);
s.Add(LanguageResources.CommonStrings.ALERT_HDR_NO);
Bind this list to dropdown.
I have the dropdownlist in the gridview itemtemplate, i need to select the value based on the dataset, i tried to bind it as "SelectedValue='<%# Eval("code") %>', but i cant find any attribute like "SelectedValue" in HTML code.
I tried below link also it was not work out to me
Eval() in a DropDownList within a GridView
Can any one help me in that
You have to understand how dropdown list (select tag) in HTML works.
E.g. if you want to select some item you have to mark it as selected as follows
<select>
<option value="a">a</option>
<option value="b" selected="1">b</option>
<option value="c">c</option>
</select>
So you have to put selected="1" to item you want to select. That means you can not do it easily using Eval method. You have to utilize server side which will do it for you.
The example given on the page you have postetd and which you said you have tried works correctly. Check whether the HTML output contains value attributes at each option. The value can differ from what is enclosed within the option tag. If the value attribute is missing that is the reason why the item is not being selected. (Use firebug or any developer console to examine).
I have an issue getting the selected value of a dropdownlist.
My view source looks like this:
<div class="editor-field">
<select class="list" id="DivisionesLists" name="DivisionesLists">
<option value=""> -- Seleccione -- </option>
<option selected="selected" value="1">COORPORATIVO</option>
<option value="2">MANUFACTURA</option>
</select>
</div>
And my controller:
string s = Request.Form["DivisionesLists"];
The problem is that Request.Form["DivisionesLists"] returns "1,1" instead of just "1" (which is the actual selected value of the dropdownlist).
What may be happening?
Thank you!!!
It might also be posting some additional data, what happens if you select the first one, what does it post back? Does it post anything back with a comma?
It could be a duplicate control... though like Html.CheckBox action method: it renders the checkbox control and a hidden field that represents the value when the checkbox isn't there; accessing the value when its checked is true,false.
HTH.
If the select isn't a multiple select I think you have another control (input or select) that have the same name attribute on the page.
I'm building a web app that will come back with a report. For certain parameters where the user has requested a dropdown list, they also want to be able to select more than one option at a time.
e.g. show me all transactions from the states of TX, WV, and ID.
The reason I've decided to go with the dropdownlist they requested and not a listbox is there are over 40 parameters they can pick from and my page is already crammed with that many controls.
You won't be able to do it with a dropdownlist directly but what you could do is fake it.
Have a hidden ListBox on your page. Construct something that looks like a dropdownlist visually (label + image would work). During the onclick event of your fake dropdownlist show your listbox underneath your dropdownlist. Hide the listbox during the onblur event for the ListBox. Also you could throw in some jquery to animate the unveiling of your listbox to more closely match the look of a dropdownlist.
try this out: have a drop down for unselected choices and a list box for selected; similar to anton lavey's suggestions but slightly less elaborate.
<style>
select { width: 200px; }
</style>
<body>
<select id="sel" onchange="list.appendChild(this[this.selectedIndex]);">
<option disabled>Select items from this list</option>
<option value="a">a</option>
<option value="c">c</option>
<option value="d">d</option>
</select><br>
<select multiple="" id="list"><option value="b">b</option></select>
<button onclick="while(list.selectedIndex > -1) { sel.appendChild(list[list.selectedIndex]); }">Remove selected</button>
</body>
ordering can be preserved if you scan through to find the right spot to insert.