on text change

Hi there,

I have a text box that when I type a file number it should call a store procedure to look at the file, and if exist the file read the information. How can I have this on .net and c# .
should I use ontextchange? if so how to setup on the back
<asp:TextBox ID="txtFile" ValidationGroup="validation1" runat="server" CssClass="form_input"></asp:TextBox>

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I'd advise you to create a button like
<asp:Button ID="btnGetFile" runat="server" Text="Get File" onclick="btnGetFile_Click" />

protected void btnGetFile_Click_Click(object sender, EventArgs e)
    // get connection string
    using (SqlConnection connection = new SqlConnection(connectionString))
        SqlCommand command = connection.CreateCommand();
        command.CommandText = "sp_Name";
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.AddWithValue("@parameterName", txtFile.Text);

        //Execute command

    //And process results

otherwise you can overload your database.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RomacaliAuthor Commented:
In this case they don't want a button they want to type the file on the text field and id exist reads the info from a particular table.
Do you think is there something else besides ontextchange I can use?
ontextchange would be fine, just remember and set autopostback on the textbox.
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Be sure you use AJAX otherwise it would be impossible for users to type in anything

Use the AJAX XMLHttp object to call the SP in a page

Goto w3schools.com for simple AJAX calling code
Ajax isnt required, it would save the entire page posting back rather than just the 1 section, but it is not a must.

When autopostback is on and you have code in the ontextchange method, the post back occurs when the focus leaves the control. Viewstate will make sure you dont lose the data entered to that point.
Yep you are write ...I mixed OnKeyUp and OnTextChange.. :)
Above requirement is written in a way making it more like using AJAX
"I have a text box that when I type a file number it should call a store procedure "...

Romacali: What you can do is When user starts typing you use OnKeyup for populating the textbox with matching file names from the database ...and as soon as user select s the file presented by AJAX..hitting enter or by any means you populate the file contents on your form...
RomacaliAuthor Commented:
humm I've never done that before.
Is there a way I can do this on a dropdown as well?
I assume that question is aimed at dshrivallabh?
RomacaliAuthor Commented:
I wanted the ontextchange
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.