I want a text box respond immediately user press any text in the textbox ... below what i am trying but not getting required results. can any one tell me how to do it?
<asp:TextBoxID="T1"runat="server"AutoPostBack=trueOnTextChanged="search_log" />
Sub search_log(ByVal Sender As System.Object, ByValE As System.EventArgs)
'Some Codes Here
End Sub
hi
In this case u have to call javascript function onkeypress of textbox then from there javascript function call serverside function.
following I am posting one small example it may be helpful to u.
Example:
<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Evaluator.aspx.cs" Inherits="Evaluator" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Sample</title> <script> function CallServerSideFunction(functionName, args) { __doPostBack(functionName, args); } </script> </head> <body> <form id="form1" runat="server" > <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:TextBox ID="txtOutput" runat="server" Text="" /> <input type="Button" id="clientButtton" Value="Click me" onclick="CallServerSideFunction('ServerFunction', 'Hello World!')" /> </form> </body></html>C# Codebehind:
using System;public partialclass Evaluator : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) {if (IsPostBack)HandleEvents(Page.Request.Params["__EVENTTARGET"], Page.Request.Params["__EVENTARGUMENT"]); }private void HandleEvents(string target,string arguments) {if (target.Equals("ServerFunction")) ServerFunction(arguments); ; }public void ServerFunction(string args) { txtOutput.Text = args; }}Thanks bro ...
The only language i know is Visual Basic ... there are a lot of examples to fire Javascripts on internet but all were useless for me coz its not my type language.
please give VB example
Well if you just want to repsond to whenever user enters text in your textbox you can either do it on client side using javascript or code behind when responding to textbox ontextchanged event.
Javascript:
You can use the onKeyPress event of the textbox to respond to user text entry as:
<asp:textbox onKeyPress="Check();" />
function Check()
{
alert("Text was entered"");
}
Or Do it code behind as:
http://msdn2.microsoft.com/en-us/library/2589b44c(vs.80).aspx
0 comments:
Post a Comment