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. Jscript in content pages

Jscript in content pages

Scheduled Pinned Locked Moved ASP.NET
helpcsharphtmlvisual-studiotutorial
13 Posts 5 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.
  • M MalarGayu

    hi friends i am using visual studio 2008. i have added a master page and some content pages i need to know how to add Jscript file in content pages and how to invoke the functions of the Jscript on the click of a button... in these content pages there is not html tags at all so how to do it can anyone plz help me in this issue K.Gayathri

    D Offline
    D Offline
    Dalek Dave
    wrote on last edited by
    #2

    This may help[^]

    ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

    1 Reply Last reply
    0
    • M MalarGayu

      hi friends i am using visual studio 2008. i have added a master page and some content pages i need to know how to add Jscript file in content pages and how to invoke the functions of the Jscript on the click of a button... in these content pages there is not html tags at all so how to do it can anyone plz help me in this issue K.Gayathri

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

      MalarGayu wrote:

      in these content pages there is not html tags at all

      Impossible. If you had no controls at all then the page would be blank, empty. Is it? Without seeing the Content placeholders you have it would be difficult to answer accurately for your situation. However, typically there is a content placeholder for additional header information where you place link or script elements that should be including in the head for that page. Otherwise you would need to add them to your masterpage.


      No comment

      M 1 Reply Last reply
      0
      • N Not Active

        MalarGayu wrote:

        in these content pages there is not html tags at all

        Impossible. If you had no controls at all then the page would be blank, empty. Is it? Without seeing the Content placeholders you have it would be difficult to answer accurately for your situation. However, typically there is a content placeholder for additional header information where you place link or script elements that should be including in the head for that page. Otherwise you would need to add them to your masterpage.


        No comment

        M Offline
        M Offline
        MalarGayu
        wrote on last edited by
        #4

        hi friends this is my content page********************* <%@ Page Title="" Language="C#" MasterPageFile="~/CampaignLayout.Master" AutoEventWireup="true" CodeBehind="Campaign.aspx.cs" Inherits="MailingCampaign.Campaign" %> put contents for campaign i need to adda JScript file seperately and write a function in it and call it in this content page button click even so how to do it K.Gayathri

        N 1 Reply Last reply
        0
        • M MalarGayu

          hi friends this is my content page********************* <%@ Page Title="" Language="C#" MasterPageFile="~/CampaignLayout.Master" AutoEventWireup="true" CodeBehind="Campaign.aspx.cs" Inherits="MailingCampaign.Campaign" %> put contents for campaign i need to adda JScript file seperately and write a function in it and call it in this content page button click even so how to do it K.Gayathri

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

          As I said, you would add the script element pointing your JavaScript file in the header content placeholder, cphHead in this case. Then you can make whatever JavaScript calls necessary since the script will be available on the page when it is rendered on the client. Always make sure to format any code snippets properly when submitting. Edit you post to correct this.


          No comment

          M 1 Reply Last reply
          0
          • N Not Active

            As I said, you would add the script element pointing your JavaScript file in the header content placeholder, cphHead in this case. Then you can make whatever JavaScript calls necessary since the script will be available on the page when it is rendered on the client. Always make sure to format any code snippets properly when submitting. Edit you post to correct this.


            No comment

            M Offline
            M Offline
            MalarGayu
            wrote on last edited by
            #6

            hi friend i wrote the javascript and called it but actually my textbox name which i am passing as parrameteris txtListname but when i give like this only it is working so how to solve this problem content page*************** javascript******************* function Validate(ctl00$cphMain$txtListname) { if (ctl00$cphMain$txtListname.value == "") { alert("you must enter the List name"); return false; } }</x-turndown>

            D 1 Reply Last reply
            0
            • M MalarGayu

              hi friends i am using visual studio 2008. i have added a master page and some content pages i need to know how to add Jscript file in content pages and how to invoke the functions of the Jscript on the click of a button... in these content pages there is not html tags at all so how to do it can anyone plz help me in this issue K.Gayathri

              D Offline
              D Offline
              Dennis E White
              wrote on last edited by
              #7

              what I typically do is add a ContentPlaceholder at the bottom (right before the closing body tag in my MasterPage.master. this way in my content pages I have a that last content placeholder that I can use for adding script code to. if you don't want to do that then at the bottom of your content placeholder all you have to do is add a script block.

              as if the facebook, twitter and message boards weren't enough - blogged

              M 1 Reply Last reply
              0
              • D Dennis E White

                what I typically do is add a ContentPlaceholder at the bottom (right before the closing body tag in my MasterPage.master. this way in my content pages I have a that last content placeholder that I can use for adding script code to. if you don't want to do that then at the bottom of your content placeholder all you have to do is add a script block.

                as if the facebook, twitter and message boards weren't enough - blogged

                M Offline
                M Offline
                MalarGayu
                wrote on last edited by
                #8

                hi dennis thanks for the reply but plz do read my latest thread to know about my issue..... now i know how to write javascript but i have another issue which i have mentioned in the latest thread of mine... K.Gayathri

                1 Reply Last reply
                0
                • M MalarGayu

                  hi friend i wrote the javascript and called it but actually my textbox name which i am passing as parrameteris txtListname but when i give like this only it is working so how to solve this problem content page*************** javascript******************* function Validate(ctl00$cphMain$txtListname) { if (ctl00$cphMain$txtListname.value == "") { alert("you must enter the List name"); return false; } }</x-turndown>

                  D Offline
                  D Offline
                  Dennis E White
                  wrote on last edited by
                  #9

                  I dont understand exactly what you are asking but I am going to assume your bit of code is not working. I am not sure what you think ctl00$cphMain$txtListname is but it's not a control that you can treat like you are trying to do. if you step through your javascript you will most likely find that ctl00$cphMain$txtListname is marked as undefined. that is because it is the id of the element and nothing more. maybe this little snippet will give you a small bit of insight though: snippet[^] hope it helps explain things a bit.

                  as if the facebook, twitter and message boards weren't enough - blogged

                  1 Reply Last reply
                  0
                  • M MalarGayu

                    hi friends i am using visual studio 2008. i have added a master page and some content pages i need to know how to add Jscript file in content pages and how to invoke the functions of the Jscript on the click of a button... in these content pages there is not html tags at all so how to do it can anyone plz help me in this issue K.Gayathri

                    B Offline
                    B Offline
                    Brij
                    wrote on last edited by
                    #10

                    According latest post in the thread, You actually need to pass the ClientId of your textbox into the validate method. And your method should be like

                    function Validate(txtClientId)
                    {
                    if (doucment.getElementById(txtClientId).value == "") {

                                        alert("you must enter the List name");
                                        return false;
                                 
                                  }
                              
                              
                         }
                    

                    and you can call the method on aspx page

                    Validate("<%=txtListname.ClientID %>")

                    Cheers!! Brij Microsoft MVP ASP.NET/IIS Visit my Blog: http://brijbhushan.net

                    M 1 Reply Last reply
                    0
                    • B Brij

                      According latest post in the thread, You actually need to pass the ClientId of your textbox into the validate method. And your method should be like

                      function Validate(txtClientId)
                      {
                      if (doucment.getElementById(txtClientId).value == "") {

                                          alert("you must enter the List name");
                                          return false;
                                   
                                    }
                                
                                
                           }
                      

                      and you can call the method on aspx page

                      Validate("<%=txtListname.ClientID %>")

                      Cheers!! Brij Microsoft MVP ASP.NET/IIS Visit my Blog: http://brijbhushan.net

                      M Offline
                      M Offline
                      MalarGayu
                      wrote on last edited by
                      #11

                      thanks for the reply it is not working for me hey the textbox is a webcontrol textbox....is it any problem for this it is not identifying the textbox id... K.Gayathri

                      M B 2 Replies Last reply
                      0
                      • M MalarGayu

                        thanks for the reply it is not working for me hey the textbox is a webcontrol textbox....is it any problem for this it is not identifying the textbox id... K.Gayathri

                        M Offline
                        M Offline
                        MalarGayu
                        wrote on last edited by
                        #12

                        hi i need to specify you all friends that my textbox is placed in a content page inside content placeholder so i need to access the id of that textbox placed inside the contentplaceholder K.Gayathri

                        1 Reply Last reply
                        0
                        • M MalarGayu

                          thanks for the reply it is not working for me hey the textbox is a webcontrol textbox....is it any problem for this it is not identifying the textbox id... K.Gayathri

                          B Offline
                          B Offline
                          Brij
                          wrote on last edited by
                          #13

                          MalarGayu wrote:

                          the textbox is a webcontrol textbox....

                          I dont think that this is a issue. Is your button, textbox are on the same content page? One other way is, Register a javascript variable and assign the ClientId of textbox from Server side (C# code) and use that variable to get the ClientId of textbox in the validate method.

                          Cheers!! Brij Microsoft MVP ASP.NET/IIS Visit my Blog: http://brijbhushan.net

                          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