Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Calling javascript for ASP textbox...

Calling javascript for ASP textbox...

Scheduled Pinned Locked Moved ASP.NET
javascriptsysadmintutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    greendragons
    wrote on last edited by
    #1

    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!

    A 1 Reply Last reply
    0
    • G greendragons

      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!

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      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>

      G 1 Reply Last reply
      0
      • A Abhishek Sur

        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>

        G Offline
        G Offline
        greendragons
        wrote on last edited by
        #3

        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(){.............} .............

        G N A 3 Replies Last reply
        0
        • G greendragons

          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(){.............} .............

          G Offline
          G Offline
          greendragons
          wrote on last edited by
          #4

          lemme try with what u told....but can u tell why im getting error that end task......

          1 Reply Last reply
          0
          • G greendragons

            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(){.............} .............

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            You may want to consider using JQuery[^]. It provides a nice easy to use framework for what you are doing and more.


            I know the language. I've read a book. - _Madmatt

            1 Reply Last reply
            0
            • G greendragons

              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(){.............} .............

              A Offline
              A Offline
              Abhishek Sur
              wrote on last edited by
              #6

              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>

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups