Sunday, March 11, 2012

Combining <asp:TextBox> with MaskedEdit Extender and calling a Web Service !

Sounds like:http://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=7311

I have found a solution to my problem. Instead of display "Hello" on the client, you can register a clientscript block with the complete javascript code to execute a web service when - for example - four digits have been entered !

The nice way of this is that now I can extend my TextBox control with all of the Ajax toolkit control extenders :-)

It goes like follows:

<formid="form1"runat="server">
<asp:ScriptManagerID="ScriptManager1"runat="server"/>
<div>
<asp:TextBoxID="txtTest"runat="server"></asp:TextBox>
</div>
</form>

protectedvoid Page_Load(object sender,EventArgs e)
{
txtTest.Attributes.Add("onKeyUp","javascript:alert('hello')");
}


Please note that the following syntax gives the same result as above, but more in Ajax style ! (so much better)

$addHandler($get("txtTest"),"keyup", keyuphandler);

function keyuphandler(e)
{
// here you can put some javascript code to do some tests and if the tests are done, you can
// activate a async call to a webservice !
}

ps: onkeyup has to be replaced by keyup like onclick has to be replaced by click, always omit the keyword "on"

No comments:

Post a Comment