当前位置: 首页>>代码示例>>C#>>正文


C# ContentManager.ToString方法代码示例

本文整理汇总了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");
    }
开发者ID:krikelin,项目名称:Fakturaadress,代码行数:82,代码来源:AddBanner.aspx.cs


注:本文中的ContentManager.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。