本文整理汇总了C#中ContentManager.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ContentManager.ToString方法的具体用法?C# ContentManager.ToString怎么用?C# ContentManager.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentManager
的用法示例。
在下文中一共展示了ContentManager.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button1_Click1
protected void Button1_Click1(object sender, EventArgs e)
{
if (!Page.IsValid)
{
return;
}
int imgWidth = new ContentManager().BannerWidth;
int imgHeight = new ContentManager().BannerHeight;
int impressions = 0; // Impressions
impressions = int.Parse(tbFrequence.Text); // Create the impressions
int Index = 0;
string Namn = tbName.Text;
Namn = Namn.Replace("'", "");
string Beskrivning = tbText.Text;
Beskrivning = Beskrivning.Replace("'", "");
string AltText = tbAltText.Text;
AltText = AltText.Replace("'", "");
string Url = tbLink.Text;
string Keywords = tbKeywords.Text;
DateTime _StartDate = StartTime.SelectedDate;
DateTime _EndDate = EndTime.SelectedDate;
System.Web.HttpPostedFile a = FileUpload1.PostedFile;
StreamReader f = new StreamReader(a.InputStream);
Byte[] Bytes = new Byte[f.BaseStream.Length];
a.InputStream.Read(Bytes, 0, Bytes.Length);
/*
* If advertisement directory does not exists,
* create it
* */
String targetDirectory = Server.MapPath("..\\ads\\");
String fileName = targetDirectory + FileUpload1.FileName;
if (!Directory.Exists(targetDirectory))
{
Directory.CreateDirectory(targetDirectory);
}
FileStream Writer = new FileStream(fileName, FileMode.Create);
Writer.Write(Bytes, 0, Bytes.Length);
Writer.Close();
Bitmap img = (Bitmap)Bitmap.FromFile(fileName);
// If the image's ratio is wrong, do not continue
if (!(img.Width == imgWidth && img.Height == imgHeight))
{
// Raise the image validator error
imageValidator.IsValid = false;
imageValidator.Text = "Bilden måste vara exakt "+imgWidth.ToString()+" pixlar bred x "+imgHeight.ToString()+" pixlar hög";
// invalidate the request
return;
}
SqlConnection Conn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString);
Conn.Open();
if (Index == 0)
{
SqlCommand Query = new System.Data.SqlClient.SqlCommand(@"INSERT INTO ads(startDate,endDate,ImageUrl,NavigateUrl,AlternateText,Keywords,Impressions,Width,Height) VALUES ('" + _StartDate.ToString("yyyy-MM-dd HH:mm:ss") + "','" + _EndDate.ToString("yyyy-MM-dd HH:mm:ss") + "','ads/" + FileUpload1.FileName + "','" + Url + "','" + AltText + "','" + Keywords + "'," + impressions.ToString() + "," + imgWidth + "," + imgHeight + ")", Conn);
Query.ExecuteNonQuery();
var id = new SqlCommand("SELECT @@IDENTITY", Conn).ExecuteScalar();
Query = new SqlCommand(@"UPDATE ads SET NavigateUrl = '"+Url.Replace("'","")+"', clicks = 0 WHERE id = " + id, Conn);
Query.ExecuteNonQuery();
}
else
{
SqlCommand Query = new System.Data.SqlClient.SqlCommand("UPDATE ads SET startDate='" + _StartDate.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss") + "',endDate='" + _EndDate.ToString("yyyy-MM-dd HH:mm:ss") + "',keywords='" + Keywords + "',AlternateText='" + AltText + "' WHERE ads.ID=" + Index + "");
Query.ExecuteNonQuery();
Conn.Close();
}
Response.Redirect("banners.aspx");
}