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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Adding asp controls using Javascript

Adding asp controls using Javascript

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-netdockerhelp
9 Posts 3 Posters 1 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
    getaccessyr
    wrote on last edited by
    #1

    Hi All, I need help regarding Javascript in asp.net. According to my requirement,we have to create a toolkit which is in one usercontrol and if we click on one control of the Toolkit.It shud add the control to the Container i.e.,Div of the Page,in which we are using this Toolkit Usercontrol,and User wants to add more than one control of same type then it should increment ID's of control automatically Like if Useradded one control then ID will be label1 if he adds another one then it will be label2 and so on. Please I need this help ASAP.Can any one help me? Thankyou In Advance

    A 1 Reply Last reply
    0
    • G getaccessyr

      Hi All, I need help regarding Javascript in asp.net. According to my requirement,we have to create a toolkit which is in one usercontrol and if we click on one control of the Toolkit.It shud add the control to the Container i.e.,Div of the Page,in which we are using this Toolkit Usercontrol,and User wants to add more than one control of same type then it should increment ID's of control automatically Like if Useradded one control then ID will be label1 if he adds another one then it will be label2 and so on. Please I need this help ASAP.Can any one help me? Thankyou In Advance

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

      I think you need to clear out the basics on how ASP.NET works. Using Javascript, you can create any html control and add it to a div container. But that doesnt means it will automatically added to the server. If you want it to be added to the server you need to postback the page and add the control. You will find each control inside Request.Form collection. ;)

      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


      My Latest Articles-->** Simplify Code Using NDepend
      Basics of Bing Search API using .NET
      Microsoft Bing MAP using Javascript

      G 1 Reply Last reply
      0
      • A Abhishek Sur

        I think you need to clear out the basics on how ASP.NET works. Using Javascript, you can create any html control and add it to a div container. But that doesnt means it will automatically added to the server. If you want it to be added to the server you need to postback the page and add the control. You will find each control inside Request.Form collection. ;)

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Simplify Code Using NDepend
        Basics of Bing Search API using .NET
        Microsoft Bing MAP using Javascript

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

        Thanks For ur reply Abhishek.. I know how to do that in server side but according to our requirement No postback shud happen in the page.As I dont know ways that how we have to do that using only javascript, i posted here ok.It doesnt mean that I dont know ASP.NET.if you know try to reply with better ways to get the solution without any postbacks just tell me.Remind that NO one is efficient as they think themselves ok,Even you. If you dont know solutions then you dont reply ok

        A S 2 Replies Last reply
        0
        • G getaccessyr

          Thanks For ur reply Abhishek.. I know how to do that in server side but according to our requirement No postback shud happen in the page.As I dont know ways that how we have to do that using only javascript, i posted here ok.It doesnt mean that I dont know ASP.NET.if you know try to reply with better ways to get the solution without any postbacks just tell me.Remind that NO one is efficient as they think themselves ok,Even you. If you dont know solutions then you dont reply ok

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

          getaccessyr wrote:

          Remind that NO one is efficient as they think themselves ok,Even you.

          I agree.... budd.. My suggestion is not meant to make you down. I just wanted to know if you know the basics clear. I have seen lots of people who doesnt knows basics right.. Well, regarding your issue, say you want to add a control in the client side, use this :

          function addElement() {
          var element = document.createElement('input');
          element.id = 'txtbox1';
          element.name = 'txtbox1';
          element.type = 'text';
          var cont = document.getElementById('mydiv');
          cont.appendChild(element);
          }

          This will add a textbox in the client side to a container div element. Now If you want to detect what value you enter in the client side to this textbox use : string valueEntered = this.Request.Form["txtbox1"]; Also if you want to control to appear in the client side, add the control to the divelement in the server side also during this postback. Actually, when postback occurs, the page is recreated in the server side and thus any client side controls that is created will be removed. If you want the textbox again, recreate the TextBox object using

          TextBox tb = new TextBox();
          tb.Text = valueEntered;
          this.mydiv.Controls.add(tb);

          I hope you are clear now. :rose:

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Simplify Code Using NDepend
          Basics of Bing Search API using .NET
          Microsoft Bing MAP using Javascript

          G 2 Replies Last reply
          0
          • A Abhishek Sur

            getaccessyr wrote:

            Remind that NO one is efficient as they think themselves ok,Even you.

            I agree.... budd.. My suggestion is not meant to make you down. I just wanted to know if you know the basics clear. I have seen lots of people who doesnt knows basics right.. Well, regarding your issue, say you want to add a control in the client side, use this :

            function addElement() {
            var element = document.createElement('input');
            element.id = 'txtbox1';
            element.name = 'txtbox1';
            element.type = 'text';
            var cont = document.getElementById('mydiv');
            cont.appendChild(element);
            }

            This will add a textbox in the client side to a container div element. Now If you want to detect what value you enter in the client side to this textbox use : string valueEntered = this.Request.Form["txtbox1"]; Also if you want to control to appear in the client side, add the control to the divelement in the server side also during this postback. Actually, when postback occurs, the page is recreated in the server side and thus any client side controls that is created will be removed. If you want the textbox again, recreate the TextBox object using

            TextBox tb = new TextBox();
            tb.Text = valueEntered;
            this.mydiv.Controls.add(tb);

            I hope you are clear now. :rose:

            Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


            My Latest Articles-->** Simplify Code Using NDepend
            Basics of Bing Search API using .NET
            Microsoft Bing MAP using Javascript

            G Offline
            G Offline
            getaccessyr
            wrote on last edited by
            #5

            ThankYou

            S 1 Reply Last reply
            0
            • G getaccessyr

              ThankYou

              S Offline
              S Offline
              sashidhar
              wrote on last edited by
              #6

              getaccessyr wrote:

              ThankYou

              If it Helps mark it as answer so tht it will be helpful to others..! ;P

              LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

              1 Reply Last reply
              0
              • G getaccessyr

                Thanks For ur reply Abhishek.. I know how to do that in server side but according to our requirement No postback shud happen in the page.As I dont know ways that how we have to do that using only javascript, i posted here ok.It doesnt mean that I dont know ASP.NET.if you know try to reply with better ways to get the solution without any postbacks just tell me.Remind that NO one is efficient as they think themselves ok,Even you. If you dont know solutions then you dont reply ok

                S Offline
                S Offline
                sashidhar
                wrote on last edited by
                #7

                getaccessyr wrote:

                if you know try to reply with better ways to get the solution

                Just Here many people just post the question without any basics..! here no body is getting paid. every one is trying to help and learn..! You ask him a question first if he replied with you a question ..!Is it Wrong..?Just to know how much you have tried?

                getaccessyr wrote:

                NO one is efficient as they think themselves ok,Even you.

                Yes thts Right..! But this is not the way to say Mr..!

                getaccessyr wrote:

                If you dont know solutions then you dont reply ok

                Its Rude..!:mad:

                LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

                1 Reply Last reply
                0
                • A Abhishek Sur

                  getaccessyr wrote:

                  Remind that NO one is efficient as they think themselves ok,Even you.

                  I agree.... budd.. My suggestion is not meant to make you down. I just wanted to know if you know the basics clear. I have seen lots of people who doesnt knows basics right.. Well, regarding your issue, say you want to add a control in the client side, use this :

                  function addElement() {
                  var element = document.createElement('input');
                  element.id = 'txtbox1';
                  element.name = 'txtbox1';
                  element.type = 'text';
                  var cont = document.getElementById('mydiv');
                  cont.appendChild(element);
                  }

                  This will add a textbox in the client side to a container div element. Now If you want to detect what value you enter in the client side to this textbox use : string valueEntered = this.Request.Form["txtbox1"]; Also if you want to control to appear in the client side, add the control to the divelement in the server side also during this postback. Actually, when postback occurs, the page is recreated in the server side and thus any client side controls that is created will be removed. If you want the textbox again, recreate the TextBox object using

                  TextBox tb = new TextBox();
                  tb.Text = valueEntered;
                  this.mydiv.Controls.add(tb);

                  I hope you are clear now. :rose:

                  Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                  My Latest Articles-->** Simplify Code Using NDepend
                  Basics of Bing Search API using .NET
                  Microsoft Bing MAP using Javascript

                  G Offline
                  G Offline
                  getaccessyr
                  wrote on last edited by
                  #8

                  hi Abhishek, Thankyou for your reply... Dont think in other way for my reply which i gave earlier ok. If u got hurted, Sorry for that.......... Wish u a Happy Christmas n New Year In Advance :)

                  A 1 Reply Last reply
                  0
                  • G getaccessyr

                    hi Abhishek, Thankyou for your reply... Dont think in other way for my reply which i gave earlier ok. If u got hurted, Sorry for that.......... Wish u a Happy Christmas n New Year In Advance :)

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

                    No problem.. I didnt hurt.. I am always like to guide people in right path, as most of others here does. Generally, I used to be very busy with my normal work in the morning, so sometimes cant give exact solution. Its ok. Merry Christmas to you too. Cheers:thumbsup:

                    Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                    My Latest Articles-->** Simplify Code Using NDepend
                    Basics of Bing Search API using .NET
                    Microsoft Bing MAP using Javascript

                    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