Custom KeyDown Control - c#

I am very new to ASP.NET and this is my first job and I need to perfom good.
I am stuck on this search page where I have two text boxes. One searches by ID which is int, the second by last name. Both the searched populate a grid view. As per the requirement when the user types in last name and clicks search the grid view should populate which I got working. Now if the user stats typing in the ID Search text box the Lastname Search text box should clear as well as the grid view that had gotten populated should be hidden.
I achieved clearing the text box by using
txtSNumberSearch.Attributes["onKeyDown"] = "clearTextBox(this.id)";
txtSNumberSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').innerText='';", txtLastNameSearch.ClientID));
txtLastNameSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').innerText='';", txtSNumberSearch.ClientID));
But am not able to clear or hide the grid view on key down in the text box, my boss says I need to create a custom key down event handler. I do not know how to do it. Any help would be appreciated as I really need to perform at this job.

An easy way of hiding the GridView is by simply adding it into a standard div and hiding that.
<div id="divGV">
<asp:GridView>...
</div>
You can hide the div by doing this in javascript:
document.getElementById("divGV").style.display='none';"
You've already got a handler added for txtLastNameSearch, so you could do something like this:
txtLastNameSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').value='';
document.getElementById("divGV").style.display='none';", txtSNumberSearch.ClientID));

Text boxes don't use InnerText. Try using value property. Keydown is just fine I think.
Try this.
txtSNumberSearch.Attributes["onKeyDown"] = "clearTextBox(this.id)";
txtSNumberSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').value='';", txtLastNameSearch.ClientID));
txtLastNameSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').value='';", txtSNumberSearch.ClientID));

Related

How to make a User Control that behaves like a combobox but with an editable textbox

I want to make a Searchbox, so i want to create a User Control, that display a textbox but when typed on will call a dropdown list similar to that of a combobox. ¿is this posible?
the input that you are describing called AutoComplete,
and WPFToolkit suggest easy to use one
https://github.com/dotnetprojects/WpfToolkit

How to get my dynamic generated controls value in asp.net C#

I have gone through many articles and similar kind of stack over flow questions. Almost I spend more than a day trying to find the solution, all goes in vain.
First I should tell you what I am trying to make.
There a simple grid having a text box currently
Similar to this article
So when I put some value to text box it generate these text boxes and checkbox within that row.(image related to above description)
There are events firing when text box value get changed , second when add new row is clicked.(Currently ignore delete button event).
What I earlier planned was like this, create controls in every postback,I have saved first row text box values in a viewstate. I create these dynamic controls in grid-row-bound function. So I create no of controls as according to value in viewstate stored value.
I thinked that on event function call I will first store the value of current controls then recreate all controls with same id and put back the value.So problem I am facing is that I can't find my controls on event fire. You can see in these two pic what happening because of that 1st pic 2nd pic.
If you want to see the code , please comment of which sections you want to see the code or full code
Here the link to the code click here

C# DevExpress GridControl : how to make search according to specific column text

Some sort of list will be displayed when the program runs
I want to make search with entering text on textedit. When I hit a button the gridview will be refreshed and show that the same values on entered text.
For example:
Firma Adı:ABC(User enters)
ABC123
ABCDEF
.
.
.
How can I make filter such that with using editValueChanged?
Thank you..
DevExpress grid offers this functionality out of the box.
You just need to display the AutoFilter row:
either programmatically using gridView.OptionsView.ShowAutoFilterRow
property
or as an end user by right clicking on the columns label area and
selecting the relevant menu entry
In addition to #GeorgeT's suggesion (which is very good, by the way -- the AutoFilter row is a crowd pleaser), one other thought.
Dev express has a control that does exactly what you appear to be attempting. It's called the "Find Panel." You can have it show up at design time from the OptionsFind properties of the gridView, and you can also have it show up at runtime via:
gridView1.ShowFindPanel();
I suspect you will find this is far better than anything you can program by hand... and with one (or zero) line(s) of code!

How can I load data when I click in another box?

I have an autocomplete on my page where I use it as a search. I want to be able to select an item that appears in the autocomplete and then when the user clicks another box it will do a postback and if there is data for the one selected, it will populate the other fields for that chosen selection.
So what I am asking, is how would I go about doing a postback when the user clicks into another textbox on the screen?
Hi you could use event from textbox (TextChanged) inside this event put your code to verify if this data is correct. Don't forget put property AutoPostBack from textbox in True. This action only can be use if the data in textbox change if for example you put
My Dog
and data not exists if you change focus nothing will happen until you change the data for example
My Cat

tetxbox with drop down control and auto complete

in my Application i have text box beside it i have drop down control.
when the user clicks on the drop down . a list of items under the drop down control should be shown. but if user type any value in the text box ( like tom, james, peter). if that value is there in the drop down . i should move the cursor to that value.
hope my Question is clear.
Any solution how to solve it would be great
thank you
what are you looking is,
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx
Just check it, Its autocomplete with dropdown
Sounds like you want something like the JQuery autocomplete plugin or if you prefer the ASP.NET AJAX Autocomplete control.
Edit- as you want a Combobox- JQuery has a lot of options for this. Here is one of them "Simple Combo".

Categories

Resources