.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

Adding meta element under head tag through javascript

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :C#
 

I have created an aspx page in sharepoint desinger with one webpart zone containing content editor webpart. 

now i want to add the meta elements like <meta name="keywords" content="a,b,c"/> through javascript. 

I have written below mentioned javascript in content editor webpart but its not coming in head section. 

<script type="text/javascript"> var meta =document.createElement('meta');

// set properties

meta.name = "keywords"; meta.content = "A,b,c";

// now add the meta element to the head

document.getElementsByTagName('head')[0].appendChild(meta);

}</script>

Anyone has any idea does my approach is right or wrong?


Thanks -NK


View Complete Post


More Related Resource Links

adding tags to the head section with SPMobilePage.OnPreInit ?

  

The OnPreInit method's remark says :"This override adds <meta> tags to the head section of the page."

Does anybody have any clue how to do it?

Way of adding items in Drop Down List or List Box using Javascript

  
The article Way of adding items in Drop Down List or List Box using Javascript was added by raja.s on Sunday, June 06, 2010.

Hi,script type="text/javascript"> function AddItem(Text,Value) { // Create an Option object var opt = document.createElement("option"); // Add an Option object to Drop Down/List Box document.getElementById("DropDownList"

Accessing a datagrid element using javascript

  
Hi all,as I'm not a .Net developer, I'm struggling with some simple problems using the language. I'm trying to insert some javascript functionality, inside my page. What I'm trying to do below...<script language=javascript> function ControlBackupFields(hasBackup) { if (hasBackup.checked = true) { document.aspnetForm.frequencyValue.enabled = true; document.aspnetForm.frequencyUnitList.enabled = true; } else { document.aspnetForm.frequencyValue.enabled = false; document.aspnetForm.frequencyUnitList.enabled = false; } } </script> <asp:datagrid id="dgData" runat="server" AutoGenerateColumns="False" PageSize="20" Width="100%" CssClass="grid" CellPadding="1"> <ItemStyle Height="20px" CssClass="tabletext2" VerticalAlign="Top"></ItemStyle> <HeaderStyle Height="20px" CssClass="tableheading2"></HeaderStyle> <Columns> <asp:TemplateColumn> <ItemTemplate> <asp:TextBox id="volumeID" Runat="server" Visible="false" /> <asp:Label id="volumeName" Runat="server" /> </ItemTemplate> </asp:TemplateColumn> <asp:Templa

How do I add an external javascript and CSS to the head of a Sharepoint page?

  
I am a web designer and I was asked to design a page for our internal sharepoint server. I created a spry page using Dreamweaver CS5, and I need to add the .js and .css to the head of the sharepoint document. I created the sharepoint page, and added my html code to the html webpart, the content displays, but I need to add the external files to the <head> tag so the content displays correctly. I tryed to open the page in SP Designer 2007, but I can't edit or add to the head tag. Help

Adding JavaScript to Default.aspx

  

Hi there,

I am relatively new to SharePoint Designer and want to add a piece of JavaScript code that I have used before on standard HTML websites but I am not 100% sure where to put the code on the page.

I tried already and got an error so I have removed the code and the page works as standard.

Below is the code I inserted to a webpartzone (right) replacing the &nbsp; which was already there.

<script type="text/javascript">
//new fadeshow(IMAGES_ARRAY_NAME, slideshow_width, slideshow_height, borderwidth, delay, pause (0=no, 1=yes), optionalRandomOrder)
new fadeshow(fadeimages, 300, 220, 0, 7000, 1)
</script>

The main script is very long so I hadnt pasted it in but i placed it at the top of the page (when in code view). Here it is below:

What am i doing wrong?

Thanks
The Commish

<script type="text/javascript"> 
/***********************************************
* Ultimate Fade-In Slideshow (v1.5): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
 
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["images/rotate01.jpg", "", "

Different head and meta tag content on each content page

  

Hi,

 I am using master pages.  I want to put different head and meta (description, keywords) on each content page. How can this be done to make my site better designed for search engines.

 

Thanks

Andrew Welch

 

Abtec Network Systems


Adding Textbox values using javascript.

  

Hi All,


i am developing an application using ASP.NET with C#.

in my application i have 4 textboxes. they are 1. Textbox1

                                                                         2.Textbox2

                                                                         3.Textbox3

                                                         &nb

Passing invisible element to javascript function

  

I want to pass the name of a listbox to a javascript function which will make it visible. The listbox element must start out invisible. But when the server generates the source, it does not create the element because it is invisible. So the javascript functions doesn't get anything. How to do this?

    function promote(boxid) {
        document.getElementById(boxid).style.visibility = "visible";
        document.getElementById(boxid).style.zIndex = 100;
    }

...

    <asp:ListBox ID="ListBox1" runat="server" CssClass="PosAbs0" Visible="False"
        SelectionMode="Multiple" ToolTip="Ctrl-Click to select multiple items">
        <asp:ListItem Selected="True">All Breed</asp:ListItem>
        <asp:ListItem>Specialty</asp:ListItem>
        <asp:ListItem>Hunting</asp:ListItem>
        <asp:ListItem>Junior</asp:ListItem>
    </asp:ListBox>


Dynamically adding a javascript control to a row.

  

Hi all,

I have an old classic asp page that uses a 3rd party javascript calendar control. On that page I dynamically build up controls on a click of a button like so:

function AddContractorRow()
{
	with (frmMain)
	{          
		var objRow = document.all.Table1.insertRow(document.all.Table1.rows.length - 2);

		objRow.style.cursor = "hand";
		objRow.id = "row";

		var objCell = objRow.insertCell();
		objCell.innerHTML = "<input class='mnwInput200' type='text' id='txtTest1' name='txtTest1' value='some val' readonly>";

		var objCell = objRow.insertCell();
		objCell.innerHTML = "<input class='mnwInput200' type='text' id='txtTest2' name='txtTest2' value='some val' readonly>";
		
		objCell = "";
		objRow = ""
	}
}


 

Basically I want to also add this JS control in another cell on the end. Normally to add this control to the page you would just declare it like so:

var calInServiceDate = new ctlSpiffyCalendarBox("calInServiceDate", "frmMain", "datInServiceDate","btnInServiceDate","<%=Date()%>");


 

Then the markup is just:

On adding WCF Service reference element is not created

  

Hi Friends,

I am using x.509 certificate based authentication in my WCF service. In development stage, I created a x.509 certificate using makecert utility. Installed it on my local machine. Added the reference to the certificate in my WCF service. When I added the service reference to my Test App, following element got created in the app.config file of the Test App.

            <endpoint address="http://localhost/MyService/MyService.svc"
                binding="wsHttpBinding" bindingConfiguration="wsHttpEndpoint"
    contract="MyService.IMyService" name="wsHttpEndpoint">
                <identity>
                    <certificate encodedValue="Long encoded string..." />
                </identity>
            </endpoint>

I then deployed the WC

On adding WCF Service reference element is not created

  

Hi Friends,

I am using x.509 certificate based authentication in my WCF service. In development stage, I created a x.509 certificate using makecert utility. Installed it on my local machine. Added the reference to the certificate in my WCF service. When I added the service reference to my Test App, following element got created in the app.config file of the Test App.

            <endpoint address="http://localhost/MyService/MyService.svc"
                binding="wsHttpBinding" bindingConfiguration="wsHttpEndpoint"
    contract="MyService.IMyService" name="wsHttpEndpoint">
                <identity>
                    <certificate encodedValue="Long encoded string..." />
                </identity>
            </endpoint>

I then deployed the WC

On adding WCF Service reference element is not created

  

Hi Friends,

I am using x.509 certificate based authentication in my WCF service. In development stage, I created a x.509 certificate using makecert utility. Installed it on my local machine. Added the reference to the certificate in my WCF service. When I added the service reference to my Test App, following element got created in the app.config file of the Test App.

            <endpoint address="http://localhost/MyService/MyService.svc"
                binding="wsHttpBinding" bindingConfiguration="wsHttpEndpoint"
    contract="MyService.IMyService" name="wsHttpEndpoint">
                <identity>
                    <certificate encodedValue="Long encoded string..." />
                </identity>
            </endpoi

Adding a JavaScript to SharePoint Page with SharePoint Designer

  

I am trying to add a javascript to a single SharePoint page. This script will only be used on this one page so I do not want to put it in the master page. I saved the the scritp to a document library on my site. Using SharePoint Designer, I opened the page on which the script should reside. I put the tag script tag at the first place I could. When I save the page, I get this error:

Content in the embedded form field may be changed by the server to remove unsafe content. Do you want to reload your page to see the results of the save?

After clicking Yes, the script tag is gone. How do I add this script to my page?


Adding a javascript to Gridview in CodeBehind.

  

Good Day everyone,


Is there a way to turn this

 <asp:TemplateField HeaderText="Price">
            <ItemTemplate>
             <asp:HyperLink ID="selectionHyperLink"
             runat="server" 
                     NavigateUrl='<%# Eval("PartNo", "javascript:popWindow('../../Synergy/Docs/HLI_CCareItemInfo.asp?close=1&Item={0}');") %>'
                     Text='<%# Eval("Price")%>'/>
                     
    </ItemTemplate>
</asp:TemplateField>
Into a Code Behind code? 
Anyone have any idea. I tried calling a TemplateField but then what do I do? 

Any help is greatly appreciated.




SAML Assertion encryption on STS, adding wsd:Id to EncryptedData element

  

Using WIF/WCF on Server2008 and .NET 3.5, trying to connect to a service on Oracle Service Bus. Policy calls for SAML Assertion, sender-vouches, asymmetric keys.

Sender-vouches seems to imply both signing and encryption of the SAML Assertion at the STS before serialization into the RSTR, implying that it doesn't get decrypted and verified until it gets all the way to the Relying Party.

Signing works fine, and encryption works fine, too. But when the client attempts to pass through the resulting encrypted "blob," it chokes with "element to sign must have id."

On closer examination, it appears that the STS does not add the wsu:id attribute to the EncryptedData element. The "wsu:Id" is more fomally known as "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd:Id," and it's essential for signing any element (with the exception of the SAML Assertion, but that's another story with another interop solution).

The wsu:Id is perfectly legal for <EncryptedData> elements, and so the answer has to be to add it at the time the element is created.

Is there a quick and easy way to get this attribute added? It can be done in WCF, but that requires all that custom plumbing. I'm looking at GovindR's ReserializeSaml at the moment, and it seems a mighty big gun for such a small task.

adding javascript breaks default page layout in vwd 2010

  

I'm putting together my first project in vwd 2010 and I'm starting with the default settings for a web form project.  I'm trying to add an external js file to a content page that inherits from the default master page.   When I add my .js file to the page, the navigation links, which normally display horizontal, desplay like a vertical list.  If I comment out the code then it displays ok.  

Here's how I'm adding my file in the code behind:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!ClientScript.IsClientScriptBlockRegistered("getNewWord"))
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "getNewWord",
            "<script language=javascript src='Scripts\\getNewWord.js'>");   
        }
    }

 The navigation markup in the master page looks like this:

            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Home.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>

JavaScript, passing reference to a form element question

  

I have a simple audio player that is controlled with JavaScript initiated by ASP.NET imagebuttons. When the user clicks on the "play" button the image is switched out for a different button image to make it "light up" while playing; when the player is finished the original image is put back so the button appears dark again. Originally, I was doing this by hardcoding in the client element ids for the image buttons ("ctl00_Middle_Voice1_LoginView1_StartLoad"), but that restricted where I could use the control. So, I have switched it so that in the ImageButton OnClientClick function I pass in 'this' and then refer to that control in the function to change the image source.

This works fine for the initial function called by OnClientClick (Play), but that function in turn calls a second function to determine the timing, control the progress bar, and whether or not the player is done playing yet and if so to swap back the original image. In that second function (Timing), I get a null object reference if I try to pass the element in again as an argument.

I have tried getting the id of the element and passing that instead (and then locating the element from the second function with getElementByID), but get the same error.

<eo:ProgressBar ID="ProgressBar1" runat="server" BorderColor="Black" BorderWidth="1px" IndicatorColor="Red" Hei
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend