Web Forms :: Programmatically Change Tag Meta?
May 7, 2010i want to change the meta tag or insert some text to it when page is up
View 1 Repliesi want to change the meta tag or insert some text to it when page is up
View 1 RepliesI have a bit of code on one of my pages (note, I'm not the original developer nor an asp.net programmer) that looks like this:
<meta id="metaDescription" runat="server" name="description" content="SEE CODE BEHIND" />
<meta id="metaKeywords" runat="server" name="keywords" content="SEE CODE BEHIND" />
The placement of the "id" element is interfering with sites that scrape the meta data resulting in it not being located on the page, so what I want to do is more the "name" element directly after <meta> and before the "id" element
I want to know if there is way to change meta description on specific pages, but to keep the meta data from the master page for the pages where I haven't specified any info.
I am trying this approach:
[code]....
Which adds the description tag properly, but I want in same time to remove/disable the meta tag from the master page. Is that possible?
I am using the mataloactor of Google. I want to change placemark of meta locator. How i will do it.
View 1 Repliescreate db driven meta keywords/description. I would store these records in a database, xml format i presume; since it would be per culture.How would i go about doing this?
View 4 RepliesI would like to change the innerHTML of a LinkButton programmatically.Example:
[Code]....How can i get ChangeThisValue changed programmatically?
I want to change the server timezone to indian timezone in site
View 1 RepliesI have a formview bound to an entitydatsource and it is working fine. here's the scenario though
If the querystring contains a "memberID" , I have setup an object datasource to fetch the results corresponding to the memberid from the database.
I want the name and email id fields in the formview to default to these values in the objectdatasource. How can you do this?
I have a GridView with an TemplateField:
<asp:GridView runat="server" ID="gvReport" ondatabinding="gvReport_DataBinding">
<Columns>
<asp:TemplateField >
<ItemTemplate>
<asp:Label runat="server" Text='<%#Eval("answers") %>' /> out of <asp:Label runat="server" Text='<%#Eval("questions") %>' />
</ItemTemplate>
</asp:TemplateField >
</Columns>
</asp:GridView>
What I'd like to do on gvReport_DataBinding is change the field the Evals point to, so I end up with something like:
<asp:Label runat="server" Text='<%#Eval("answers_foo") %>' /> out of <asp:Label runat="server" Text='<%#Eval("questions_foo") %>' />
I have gotten this far:
TemplateField tf = ((TemplateField)gvReport.Columns[0]);
But I'm not sure what I should be doing with tf. tf.SomeProperty.Replace("answers", "answers_foo")?
Or am I barking up the wrong airplane on this one?
I have a gridview that has certain values in it that I would like to change based on a condition. For example, if a value in the column is 'x', I would like to make that Value Bold and have text that says 'Not applicable'
How can I do this? How can I programtically chnage values in a gridview?
Here is my GridView
<asp:GridView ID="GridView1"
I've a control
<asp:Button ID="btnAjax" runat="server" Text="Ajaxified" OnClick="btnAjax_Click" />
Now from the code behind I want to change the ID of the button
btnAjax.ID = "newButtonID";
But it is now working. Is it possible at the first place?
EDIT
I've created the control in the HTML mark up and not through code.
Me with C#.net, I had intalled a new keybord layout and I want to enter data in the textbox using the new keyboard language but save the details in sql server table in default keyboard layout . So how can I change the keyboard layout only at the time of insertion
View 2 RepliesI am learning .net and building a table from code behind and attempting to change alternate row colors.I have it working but at he moment only using Drawing.Color when I would like to use a hexidecimal value, is there a way of doing this?Here is the code thats doing it at the moment:
If j Mod 2 = 1 Then
r.BackColor = Drawing.Color.Aquamarine
'Table1.Rows(j).Cells(i).CssClass = "odd"
[code]...
I have wrote the below code to get and show data in GridView
Code:
[code]....
Now i want to change the captions of each column programatically.
I have a drop down list that is populated in the page load event from a database table. The drop down has a DataTextField set to a project name and the DataValueField set to the project id (interger). Later I change the dropdowlist selected item with this code in the selectedindexchanged event of a gridview
GridViewRow row = GridView1.SelectedRow;
ddlProjectList.SelectedItem.Text = row.Cells[2].Text;
Does Changing the drop down list with this code cause the DataValueField property to change to the correct Project ID number also? If not is there a better way to do this? actually this code seems to be adding an additional item to the list so that the project i set with this code is listed twice so I don't think my code is correct
I have an ajax tabcontainerpanel. What I would like to do is programatically change the text (header template text value) of one of the TabPanels (ID="TabPanel10B") depending on the selected option of a dropdownlist. Is this possible?
View 2 RepliesI'm trying to use one ImageButton as both a login button and a logout button. Initially its a login button. I click the button once and it runs the login click handler and pops up a text box to type in a password. Then I enter the password to login. Inside the password box's submit handler I check to see if the password is valid. If it is, I enable all the password protected functionality on the page, change the button's image from the login image to the logout image, and change the button's click handler from the login Click handler to the logout Click handler.
So far my code just swaps the button's image but the click handler never changes to the logout handler. I have tried two ways of changing the ImageButton's click handler programmatically and both have failed:
1.
loginBtn.Attributes.Remove("OnClick");
loginBtn.Attributes.Add("OnClick", "logoutBtn_Click");
2.
loginBtn -= new ImageClickEventHandler(loginBtn_Click);
loginBtn += new ImageClickEventHandler(logoutBtn_Click);
Neither the login text box or the login/logout button are inside an UpdatePanel. EnableViewState is set to the default of true. Does anyone see what is preventing the Click handler from being changed?
I am working on a localization project, some of the localized text are in graphics, some of the example graphics paths:
/en/images
/es/images
/fr/images
My web forms use <asp:image> controls and <img> tags (runat = sever) to point to graphics in /en/images. I need to a function to loop through all image control and point them to different paths based on the locale set at runt time. Which event should I override and how do I write it?
All my web pages inherit from a base page, I don't know if that makes differences.
gridview:
<asp:CommandField ShowDeleteButton="false" />
How to change visibility programatically from Page_load method?
I have an ASP.NET website application, and there is a home page for my web site. I need to be able to change the default document of my website programmatically (C#) so that I can make another web page take priority above the one that already exists. I would then like to revert back to the previous default document order.
Example :
I have two home pages - Home1.aspx and Home2.aspx. In the IIS default document settings I have added the two pages and made Home1.aspx be the first default document then Home2.aspx the second. I need in some cases to be able to change the order of the two default documents so that Home2.aspx is the first default document then Home1.aspx the second.
How can I do that from my C# code?
I have implemented master pages using this example How to implement a status bar in an ASP.NET application?. I have a property on my SiteMaster.cs inherited MasterPage called Environment. On my MasterPage.master I have this code:
<body>
<form id="frmMaster" runat="server">
<.. some content removed for brevity ...>
Environment: <%= this.Environment %>
</form>
</body>
What I would like to do is evaluate this.Environment and if it is "LIVE" then colour the background of this.Environment text red, and if it's "TEST" colour it yellow. How would I do this?
UPDATE I've just added this code to MasterPage.master
protected void Page_Load(object sender, EventArgs e)
{
lblEnvironment.Text = this.Environment;
if (this.Environment == "LIVE")
{
lblEnvironment.BackColor = System.Drawing.Color.Red;
}
}
The page loads, but the text does not get set, it's blank! Also the old text, that was populated is now blank too (I left the old code there for now). I also get a warning in Visual Studio:
'ASP.masterpage_master.Page_Load(object, System.EventArgs)' hides inherited member SiteMaster.Page_Load(object, System.EventArgs)'. Use the new keyword if hiding was intended.
UPDATE2: This is what I have in SiteMaster.cs
using System;
using System.Web.UI;
public class SiteMaster : MasterPage
{
public string StatusText { get; set; }
public string StatusTime { get; set; }
public string Environment { get; set; }
protected virtual void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (Session["status"] != null)
{
this.StatusText = Session["status"].ToString();
this.StatusTime = Session["statusTime"].ToString();
}
this.Environment = Session["environment"].ToString();
}
}
}
I know it possible to do this in Javascript but I not sure how to do this in C#.
I would rather not use a javascript callback function.
I am new programmer with ASP and C#.
I am working in a Silverlight 4 + RIA Services application. On the server side I am using Entity Framework and SQL Server. The user authentication is performed in the application using the default ASP.NET Membership Provider.
I am also using some profile properties to store some user preferences. Unfortunately I came across a situation where I have to change one of this properties in all users.
Altought I am using EF to manage data persistence, the ASP Membership provider tables are not in my entities diagram, since everything I must do regarding membership is performed using the objects available on the provider.
So I was thinking to use this objects to change the user prefrences, but my question is about what happens if something fails? Is there any transaction object I could use on the Membership objects to perform an atomic operation?
I know EF supports transactions, but in this case I would have to add the asp.net membership tables to my diagram.. only for that operation.
I need to change padding for one column in ASP.NET GridView, while all other CSS atributes defined in external CSS file should be left untouched. How can I do it? Update: Below is my code that solved the problem:
protected void gvwMaster_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Attributes.Add("style", "padding:0");
}