Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在c代码中添加占位符?_C#_Placeholder_10gen Csharp Driver - Fatal编程技术网

C# 如何在c代码中添加占位符?

C# 如何在c代码中添加占位符?,c#,placeholder,10gen-csharp-driver,C#,Placeholder,10gen Csharp Driver,如何在c代码中添加占位符?我想在我的表单中显示DateTime <div class="col-md-10"> @Html.EditorFor(model => model.Date, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Date, "", new { @class = "text-danger"

如何在c代码中添加占位符?我想在我的表单中显示DateTime

<div class="col-md-10">
  @Html.EditorFor(model => model.Date,  new { htmlAttributes = new { @class = "form-control"  } })
  @Html.ValidationMessageFor(model => model.Date, "", new { @class = "text-danger" })
</div>

@EditorFor(model=>model.Date,new{htmlAttributes=new{@class=“form control”})
@Html.ValidationMessageFor(model=>model.Date,“,new{@class=“text danger”})
您是否已尝试-

  @Html.EditorFor(model => model.Date, new { placeholder =  DateTime.Now.ToString("MM/dd/yyyy")})

请描述一下你提出的解决方案。我确实在我的评论中解释了我自己。
/** Here is how I did it in my code. I had a richtexBox5 that I needed to add QTY placeholder. So what did was, inside public form i did the following */
  public Form1()
        {
            InitializeComponent();

         richTextBox5.Text = "QTY";// set text you want to show

         if (richTextBox5.Text == "QTY")
            {
             richTextBox5.ForeColor = Color.LightGray;// set color
           }
        }

/**now make this function which will listen to mouse click  in wherever part you want*/
 private void richTextBox5_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {           
            if(richTextBox5.Text=="QTY") // check what is in that textbox
            {
                richTextBox5.Text = "";// set it to null 
                richTextBox5.ForeColor = Color.Black;// change color
            }      
        }