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.
Related
I would like to ask how I can focus on a specific item in the long list via a search bar.
example: when a user enters something on the search bar, the list is filtered to find the elements that contain that search key, I would like that if at least one result is found, the focus is placed on the first element found.
when user visit the page:
after the user search a something:
thanks!
i don't know if this solves your problem or not u can use datalist tag in html which work kind of similar it will filter everything except what u have typed in search box instead of focusing at that element.
<label for="browser">Choose your browser from the list:</label>
<input list="browsers" name="browser" id="browser">
<datalist id="browsers">
<option value="Edge">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
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.
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).
Question - Re: R brew package with HTML (using Rook)
When using forms to retrieve queries, usually when the screen refreshes, the user's preselected option remains selected in the form. For eg., if there was a name field and I enter John,... enter other form data, hit Submit, when the page refreshes, the form will still show "John" in the name field instead of an empty box.
I can pre-fill an entry in a text type input field using something like --
...
<input class="someclass" type="text" name="Name" value="<%=Name%>" />
... (other form data)
When the user hits submit and the page refreshes, R prefills the name field with the value from <%=Name%>
I'm having some difficult in replicating the same when using drop-down menus. The idea is that when the page refreshes, the option that the user had selected in the previous query will be active.
<select class="someclass" name="group3" style="width:200px;">
<option value="," selected>None</option>
<option value="Name,">Name)</option>
<option value="Phone">Phone</option>
</select>
I think one way could be to enter something like say,
<%if (group3=="Name"){ print("selected") } ... etc for each of those options in the respective lines, but that is a bit cumbersome. Could you please share your thoughts on the same,
Got this working using jQuery finally. The inline <%= if(..) print ("selected") ... within the tags wasn't working.
Add the id=something tag to select --
<select class="someclass" name="group3" id="myselect" style="width:200px;">
<option value=",">None</option>
<option value="Name">Name)</option>
<option value="Phone">Phone</option>
</select>
Add jquery.js to the html file in the header--
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
In my Rook brew file, I have something like,
forminput <- req$GET()
userselection <- forminput$group3 #group3 is the class name for the select statement
and in the HTML document, before the closing form tag, enter the following --
<script>
$("#myselect").val("<%=userselection%>").attr("selected", "selected");
</script>
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.