Client side Javascript assigning the default Static values to UserName and Email










-1















Hi I worte a js client side and rendered that server side aswell when i user filling the form the Username field need to be simultaneously filled based on Email input before submiting the form.
My query is in the Email field and Username field the values "UserName"
and "Email" are appearing by Default and also i cant edit the email field the forms is able to submit with valuse UserName and Email which is not i am looking.
the below code is my client side JS



<asp:TextBox ID="Email" runat="server" onkeyup="change();"></asp:TextBox>
function change()
document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName').value = 'UserName';
document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email').value = 'Email';
UserName.value=Email.value;



The below is my C# which i used stringbuilder



protected override void RenderContents(HtmlTextWriter writer)
{

System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
sb2.AppendLine(@"<script language='javascript'>");
sb2.AppendLine(@"function change()");
sb2.AppendLine(@"var Email= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
sb2.AppendLine(@"var UserName= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
sb2.AppendLine(@"UserName.value=Email.value;");
sb2.AppendLine(@" ");
sb2.Append(@"</script>");

if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))

Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());




The reason i added my code into C# stringbuilder is i am unable to get the java code on clientside when checked using f12 i am not able to see any of the java code which i wrote on aspx page so i used string builder to get that code.



Thanks










share|improve this question


























    -1















    Hi I worte a js client side and rendered that server side aswell when i user filling the form the Username field need to be simultaneously filled based on Email input before submiting the form.
    My query is in the Email field and Username field the values "UserName"
    and "Email" are appearing by Default and also i cant edit the email field the forms is able to submit with valuse UserName and Email which is not i am looking.
    the below code is my client side JS



    <asp:TextBox ID="Email" runat="server" onkeyup="change();"></asp:TextBox>
    function change()
    document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName').value = 'UserName';
    document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email').value = 'Email';
    UserName.value=Email.value;



    The below is my C# which i used stringbuilder



    protected override void RenderContents(HtmlTextWriter writer)
    {

    System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
    sb2.AppendLine(@"<script language='javascript'>");
    sb2.AppendLine(@"function change()");
    sb2.AppendLine(@"var Email= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
    sb2.AppendLine(@"var UserName= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
    sb2.AppendLine(@"UserName.value=Email.value;");
    sb2.AppendLine(@" ");
    sb2.Append(@"</script>");

    if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))

    Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());




    The reason i added my code into C# stringbuilder is i am unable to get the java code on clientside when checked using f12 i am not able to see any of the java code which i wrote on aspx page so i used string builder to get that code.



    Thanks










    share|improve this question
























      -1












      -1








      -1








      Hi I worte a js client side and rendered that server side aswell when i user filling the form the Username field need to be simultaneously filled based on Email input before submiting the form.
      My query is in the Email field and Username field the values "UserName"
      and "Email" are appearing by Default and also i cant edit the email field the forms is able to submit with valuse UserName and Email which is not i am looking.
      the below code is my client side JS



      <asp:TextBox ID="Email" runat="server" onkeyup="change();"></asp:TextBox>
      function change()
      document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName').value = 'UserName';
      document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email').value = 'Email';
      UserName.value=Email.value;



      The below is my C# which i used stringbuilder



      protected override void RenderContents(HtmlTextWriter writer)
      {

      System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
      sb2.AppendLine(@"<script language='javascript'>");
      sb2.AppendLine(@"function change()");
      sb2.AppendLine(@"var Email= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
      sb2.AppendLine(@"var UserName= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
      sb2.AppendLine(@"UserName.value=Email.value;");
      sb2.AppendLine(@" ");
      sb2.Append(@"</script>");

      if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))

      Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());




      The reason i added my code into C# stringbuilder is i am unable to get the java code on clientside when checked using f12 i am not able to see any of the java code which i wrote on aspx page so i used string builder to get that code.



      Thanks










      share|improve this question














      Hi I worte a js client side and rendered that server side aswell when i user filling the form the Username field need to be simultaneously filled based on Email input before submiting the form.
      My query is in the Email field and Username field the values "UserName"
      and "Email" are appearing by Default and also i cant edit the email field the forms is able to submit with valuse UserName and Email which is not i am looking.
      the below code is my client side JS



      <asp:TextBox ID="Email" runat="server" onkeyup="change();"></asp:TextBox>
      function change()
      document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName').value = 'UserName';
      document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email').value = 'Email';
      UserName.value=Email.value;



      The below is my C# which i used stringbuilder



      protected override void RenderContents(HtmlTextWriter writer)
      {

      System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
      sb2.AppendLine(@"<script language='javascript'>");
      sb2.AppendLine(@"function change()");
      sb2.AppendLine(@"var Email= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
      sb2.AppendLine(@"var UserName= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
      sb2.AppendLine(@"UserName.value=Email.value;");
      sb2.AppendLine(@" ");
      sb2.Append(@"</script>");

      if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))

      Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());




      The reason i added my code into C# stringbuilder is i am unable to get the java code on clientside when checked using f12 i am not able to see any of the java code which i wrote on aspx page so i used string builder to get that code.



      Thanks







      javascript






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 17:15









      RamSPRamSP

      12




      12






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I managed to fix the issue.
          I have used the below code



          function change() 
          var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');
          var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');
          UserName.value = Email.value;


          System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
          sb2.AppendLine(@"<script language='javascript'>");
          sb2.AppendLine(@"function change()");
          sb2.AppendLine(@"var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
          sb2.AppendLine(@"var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
          sb2.AppendLine(@"UserName.value=Email.value;");
          sb2.AppendLine(@" ");
          sb2.AppendLine(@"</script>");
          if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))

          Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());




          Thanks






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286337%2fclient-side-javascript-assigning-the-default-static-values-to-username-and-email%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I managed to fix the issue.
            I have used the below code



            function change() 
            var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');
            var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');
            UserName.value = Email.value;


            System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
            sb2.AppendLine(@"<script language='javascript'>");
            sb2.AppendLine(@"function change()");
            sb2.AppendLine(@"var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
            sb2.AppendLine(@"var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
            sb2.AppendLine(@"UserName.value=Email.value;");
            sb2.AppendLine(@" ");
            sb2.AppendLine(@"</script>");
            if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))

            Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());




            Thanks






            share|improve this answer



























              0














              I managed to fix the issue.
              I have used the below code



              function change() 
              var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');
              var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');
              UserName.value = Email.value;


              System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
              sb2.AppendLine(@"<script language='javascript'>");
              sb2.AppendLine(@"function change()");
              sb2.AppendLine(@"var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
              sb2.AppendLine(@"var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
              sb2.AppendLine(@"UserName.value=Email.value;");
              sb2.AppendLine(@" ");
              sb2.AppendLine(@"</script>");
              if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))

              Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());




              Thanks






              share|improve this answer

























                0












                0








                0







                I managed to fix the issue.
                I have used the below code



                function change() 
                var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');
                var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');
                UserName.value = Email.value;


                System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
                sb2.AppendLine(@"<script language='javascript'>");
                sb2.AppendLine(@"function change()");
                sb2.AppendLine(@"var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
                sb2.AppendLine(@"var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
                sb2.AppendLine(@"UserName.value=Email.value;");
                sb2.AppendLine(@" ");
                sb2.AppendLine(@"</script>");
                if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))

                Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());




                Thanks






                share|improve this answer













                I managed to fix the issue.
                I have used the below code



                function change() 
                var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');
                var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');
                UserName.value = Email.value;


                System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
                sb2.AppendLine(@"<script language='javascript'>");
                sb2.AppendLine(@"function change()");
                sb2.AppendLine(@"var Email = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
                sb2.AppendLine(@"var UserName = document.getElementById('ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
                sb2.AppendLine(@"UserName.value=Email.value;");
                sb2.AppendLine(@" ");
                sb2.AppendLine(@"</script>");
                if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))

                Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());




                Thanks







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 14 '18 at 15:57









                MarSPMarSP

                14




                14





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286337%2fclient-side-javascript-assigning-the-default-static-values-to-username-and-email%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                    Darth Vader #20

                    Ondo