Calling javascript for ASP textbox...
-
Hello, I want to know how to call javascript function for asp textbox.... like i have created <asp:TextBox ID="search" runat="server"/> i wanna create a javascript function which checks some condition and triggers onblur and onfocus for this textbox......since it is runat server how to do that... THNX!
-
Hello, I want to know how to call javascript function for asp textbox.... like i have created <asp:TextBox ID="search" runat="server"/> i wanna create a javascript function which checks some condition and triggers onblur and onfocus for this textbox......since it is runat server how to do that... THNX!
From codebehind use search.Attributes.Add("onblur", "javascript:CheckMyConditions(this);"); where
CheckMyConditions
is your javascript function which checks the values. :rose:Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Microsoft Bing MAP using Javascript
CLR objects in SQL Server 2005
Uncommon C# Keywords/xml> -
From codebehind use search.Attributes.Add("onblur", "javascript:CheckMyConditions(this);"); where
CheckMyConditions
is your javascript function which checks the values. :rose:Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Microsoft Bing MAP using Javascript
CLR objects in SQL Server 2005
Uncommon C# Keywords/xml>Thnx :)....can i similarly add a function which is called on onload to this textbox.... im little confused..and also when im trying to add .js file as javascript source im getting typeLibBuilder stopped working error..... like this is the function i wanna call myjsfile.js window.onload= initAll; function initAll(){ document.getElementById(....id of text box).onblur= blur; document.getElementById(....id of text box).onfocus= focus; function blur(){.............} function focus(){.............} .............
-
Thnx :)....can i similarly add a function which is called on onload to this textbox.... im little confused..and also when im trying to add .js file as javascript source im getting typeLibBuilder stopped working error..... like this is the function i wanna call myjsfile.js window.onload= initAll; function initAll(){ document.getElementById(....id of text box).onblur= blur; document.getElementById(....id of text box).onfocus= focus; function blur(){.............} function focus(){.............} .............
lemme try with what u told....but can u tell why im getting error that end task......
-
Thnx :)....can i similarly add a function which is called on onload to this textbox.... im little confused..and also when im trying to add .js file as javascript source im getting typeLibBuilder stopped working error..... like this is the function i wanna call myjsfile.js window.onload= initAll; function initAll(){ document.getElementById(....id of text box).onblur= blur; document.getElementById(....id of text box).onfocus= focus; function blur(){.............} function focus(){.............} .............
-
Thnx :)....can i similarly add a function which is called on onload to this textbox.... im little confused..and also when im trying to add .js file as javascript source im getting typeLibBuilder stopped working error..... like this is the function i wanna call myjsfile.js window.onload= initAll; function initAll(){ document.getElementById(....id of text box).onblur= blur; document.getElementById(....id of text box).onfocus= focus; function blur(){.............} function focus(){.............} .............
greendragons wrote:
javascript source im getting typeLibBuilder stopped
Hey, I think this might help you. http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=322157[^] This seems to be a bug in Visual Studio 2008 for 64Bit machines. Lets try out the workarounds.. If you can fix it.
greendragons wrote:
like this is the function i wanna call myjsfile.js
Yes of course. Just define a function in your JS file, add that using script tag and call its function. Say you write like this :
function selectValue(obj)
{
alert(obj.value);
}If you write
txtbox.Attributes.Add("onblur", "javascript:selectValue(this);");
It will eventually produce an alert message with the value you provided in the textbox. Other than that, if you want to call like this : window.onload=initAll; The function declaration of initAll should be before the actual call. Otherwise undefined handler will be assigned to the event. :) Hope this helped you. :thumbsup:Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Microsoft Bing MAP using Javascript
CLR objects in SQL Server 2005
Uncommon C# Keywords/xml>