Hi every one
i want use meta tag in my page that read keyword from database
i set this code in my product.aspx page
protected void Page_Load(object sender, EventArgs e)
{
SqlCommand _cmd = new SqlCommand("select Keyword1 + ',' + Keyword2 + ',' +Keyword3 from House_info where BehCode=1115", _cn);
_cn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
while (_dr.Read())
{
HtmlMeta htmlMeta;
string keyword = _dr[0].ToString();
htmlMeta = new HtmlMeta();
htmlMeta.HttpEquiv = "keywords";
htmlMeta.Content = keyword;
this.Page.Header.Controls.Add(htmlMeta);
}
}
it worked correctly and show my keywords from database and show it in my product.aspx metatag
i have two other page
index.aspx and store.aspx in index.aspx i have 1button and 1 TextBox when user type their BEHCODE(columns name in users table) in TextBox it go to store.aspx page and show that users information on store.aspx
Now i want set meta tag in store.aspx page and i want fill store.aspx meta tag from my users table in data base
this is index.aspx
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
string data = Server.UrlEncode(txtNumeric.Text);
SqlCommand _cmd = new SqlCommand("traidname", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cmd.Parameters.Add("@BehCode", data);
_cn.Open();
string tName = _cmd.ExecuteScalar().ToString();
_cn.Close();
Response.Redirect(tName + "?BehCode=" + Server.UrlEncode(txtNumeric.Text));
and store.aspx behind code
SqlCommand _cmd = new SqlCommand("storeInfo", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cmd.Parameters.AddWithValue("@BehCode",data);
_cn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
while (_dr.Read())
{
HtmlMeta htmlMeta;
string keyword = _dr[0].ToString();
htmlMeta = new HtmlMeta();
htmlMeta.HttpEquiv = "keywords";
htmlMeta.Content = keyword;
this.Page.Header.Controls.Add(htmlMeta);
Lblbehcode.Text = _dr["Name"].ToString();
Image1.ImageUrl = "~/image/behcode/" + _dr["Image_Behcode"].ToString();
here when i run website this error occur
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
in this line
this.Page.Header.Controls.Add(htmlMeta);
i use this code too
<script type="text/javascript">
$("input[id$=btnButton]").live("click", function () {
return confirm("Do you want to submit?");
});
</script>
but it didn't worked this problem just happen here when i used meta tag code in other page it worked correctly .
why this happen?
thanks