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