enabling search option in combobox - c#

<asp:ComboBox ID="ddlfrom" runat="server"
DataTextField="name" DataValueField="name" MaxLength="0"
style="display: inline;"
AutoCompleteMode="SuggestAppend">
</asp:ComboBox>
this is the asp code for my combobox...i am populating my combobox from database.I have all the city names in my combobox.Now i have enabled suggest append as you can see..but its not searching the elemnts anywhere from the names..mean when i type "SBC" code it searches for bangalore city..but i need that when i type "bang" in this also it should show me bangalore city..the same functionality as we have in makemytrip site..how can i do that..??..plzz help..

You are asking for autocomplete feature.
See this link.
You can do it using the jQuery.ajax functions. This Article explains how you can do it.

Related

Making asp:CheckBoxList Items Side By Side

I have a problem and i couldn't find the solution on web. I'm using asp CheckBoxList but i have too many data to list. I want to list items like in 2 column in box area. I'm sharing an image. Please check it out. So how can i do something like that?
The important thing is; this checkboxlist filling dynamically from code behind. I dont have ListItem on html page. So i cant style them. Any idea?
<asp:CheckBoxList ID="AreaCheckBoxes" runat=server>
</asp:CheckBoxList>
You can set the RepeatColumns property to 2 and the RepeatLayout property to Table.
<asp:CheckBoxList ID="AreaCheckBoxes"
RepeatColumns="2"
RepeatLayout="Table"
RepeatDirection="Vertical"
runat=server>
</asp:CheckBoxList>

JQuery Live Search using json with ASP.net

I have a asp.net application.The requirement is to provide a live search functionality to search a particular list of products.
I searched various live search jquery plugins and used this
http://nakajima.github.com/jquery-livesearch/
In the above mentioned link , the data is in ul li format and then the live search is implemented on that list, so what I did is in the backend, from server side, used a repeater control, like below
<ul id="names">
<asp:Repeater ID="SomeRepeater" runat="server" OnItemCommand="SomeRepeater_ItemCommand" Visible="false">
<ItemTemplate>
<li>
<asp:LinkButton ID="SomeLink" runat="server" CommandName="Load" CommandArgument='<%# Eval("SomeId")%>' Text='<%# Eval("SomeNameName") + " " + "("+ Eval("SomeCount") + ")" %>'></asp:LinkButton>
</li>
</ItemTemplate>
</asp:Repeater>
After this in the code behind, binded the repeater control with a List object for the data.
After all this the live search functionality was completely working fine with the values in repeater control as ul li.
now , the requirement is changed and I need to hide the ul li values which I am binding to repeater control, but want the live search for the same listobject.
For this I searched over the internet and got an idea, instead of using the repeater control, let me use a JSon , I am successful in getting the values as a string from the below code
JavaScriptSerializer jss = new JavaScriptSerializer();
string output = jss.Serialize(newListObject);
but the problem is , I cannot use the jquery plugin which I have mentioned above and I am not sure how to do the same search functionality using above json string.
Please let me know if my approach is correct also, how to go about achieving the same.
It sounds like jQuery Autocomplete will do exactly what you need. It's also fairly easy to integrate with .NET, you just return a list of strings.
Alternatively, you can declare a static list of autocompleteable items. You can also trigger changes/redirect when an item is clicked.

how to make the dropdownlist in edit mode

<asp:DropDownList ID="ddlReportFavorite" runat="server" Height="16px"
Width="190px">
</asp:DropDownList>
I need to have the dropdownlist to be editable, that is when a user wants to type, it allows to type. Thanks.
EDIT
Is there any method using javascript or any other alternative without going for Ajax Control Toolkit. Thanks.
You can use a bootstrap select picker and add extra attributes to your asp:dropdownlist such as the following:
<asp:DropDownList ID="ddlEditStatusCode"
runat="server"
CssClass="form-control selectpicker"
data-live-search="true"
data-size="10">
</asp:DropDownList>
You also need to add bootstrap-select.css and bootstrap-select.js to your web page.
The result should be like this:
Have a look at the ajax control toolkit, in particular...
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ComboBox/ComboBox.aspx
and a decent tutorial here
http://www.asp.net/web-forms/tutorials/ajax-control-toolkit/combobox/how-do-i-use-the-combobox-control-cs
Just have a look at jQuery Searchable DropDown Plugin
jQuery Searchable DropDown Plugin Demo

ASP.Net repeator, click and go to respective record on next page.How?

i worked in PHP before and used to use window.location function with javascript function, please let me know how to tackle the functionality in repeator,
record 1
record 2
record 3
I want if some one clicks on a label, it should go to other page, page.aspx?id=1 or id=7 respectively
I dont want to use javascript window.location, is there any built in asp.net option in repeater to do so, i have passed postback url to page.aspx.
Thanks
Atif
Drop a DataPager in your page and set it's PagedControlID attribute to your repeater's ID
<asp:Repeater ID="Repeater1" runat="server">
</asp:Repeater>
<asp:DataPager ID="DataPager1" PagedControlID="Repeater1" PageSize="5" runat="server">
</asp:DataPager>
Update:
Apparently DataPager doesn't like Repeater, so I suggest using ListView instead. In the end ListView is very much like Repeater but more flexible.

How to make a button not show up but still be used by javascript?

I am using a button that has to be invible and should be used by a javascript function.
<asp:Button ID ="btnDummy1" runat="server" Visible ="true" OnClick="btnSubmit1_Click" width="0px" height="0px"/
I cannot keep visible = false as it the javascript will not use invible content in the poage. I havetried to give width=0 and height=0, still it showws up in Chrome. What do you guys think i should do?
Thanks in advance :)
A pretty clean approach in ASP.Net it give it a "hidden" class:
<asp:Button ID ="btnDummy1" runat="server" CssClass="hidden" />
Then in your stylesheet:
.hidden { display: none; }
If you set it to Visible="False" then the code will not be executed.
Instead I think you should wrap it in a <div> and set display:none via css:
<div style="display: none;">
<asp:Button ID ="btnDummy1" runat="server" OnClick="btnSubmit1_Click" />
</div>
adding style="display:none" would hide the button till you make it visible again
<asp:Button ID ="btnDummy1" runat="server" OnClick="btnSubmit1_Click" style="display:none"/>
How about
style="display:none"
for the button instead of Visible = "true".
Can you just use a hidden form field in this case? This is generally the preferred method of passing information along.
See http://www.tizag.com/htmlT/htmlhidden.php
<asp:Button ID="btnMyOrders" runat="server" Text="my orders" CssClass="dropdown-item" OnClick="btnMyOrders_Click" Visible="False" />
Example then in Form(){
btn.Visible = true; to show it again
}
I think the first question you should ask yourself is : why would I put in my HTML doc a button that should not be visible ?
An HTML document should be used ONLY TO DESCRIBE A CONTENT'S SEMANTICS. So an HTML doc should ONLY contain the content you want to publish and extra data to explain the content's SEMANTIC !! NOTHING about the way it is displayed, NOTHING about the way it behaves !!
All displaying and behaviors questions should be managed with CSS and Javascript, NEVER within HTML itself.
Any element needed for Javascript only purpose should be added in the doc by Javascript itself !
You should never find, in an HTML doc, such things as prev/next buttons for a javascript picture gallery for example. The HTML doc should only contain the pictures list, than your JS script will change the way this list is shown, making it a eye candy gallery and add buttons for navigation.
So in your example, your saying you want to add in your HTML doc an invisible button with some Javascript actions on it.... that's probably an example of some content that should never be in the HTML doc.

Categories

Resources