小编Kin*_*her的帖子

创建密码字段@ html.TextBoxFor

模型类

[Required(ErrorMessage = "Pass word is required")]
//[ValidatePasswordLength]
[DataType(DataType.Password)]
//[Display(Name = "Password")]
public string Password { get; set; }
Run Code Online (Sandbox Code Playgroud)

视图

<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Password, new {@class="form-control",placeholder="Password" })
@Html.ValidationMessageFor(model => model.Password)

</div>
Run Code Online (Sandbox Code Playgroud)

我google了它.我发现使用@html.Editor而不是@ html.TextBoxFor但我必须为文本框应用css.

我用过 @Html.TextBoxFor(model => model.Password, new {@class="form-control",placeholder="Password" })但css没有应用.我如何实现这一目标?

asp.net asp.net-mvc razor

12
推荐指数
3
解决办法
5万
查看次数

在 Postgresql 中存档旧数据

我目前期待有人就我将要推进的数据库归档过程向我提出建议。

我有数据库 (DB-1),它有 2 个非常大的表,一个表有 25 GB 的数据,另一个是 20 GB 的数据。即使我有索引,这也会导致主要的性能问题。

因此,我们考虑使用以下过程归档旧数据,

  1. 从现有数据库 (DB-1) 克隆一个新数据库 (DB-2)。
  2. 从 DB-1 中删除旧数据,因此它将只有最近 2 年的记录。如果我需要旧数据可以连接 DB-2。
  3. 每个月应该将旧数据从 DB-1 移动到 DB-2,并从 DB-1 中删除移动的行。

postgresql archiving

9
推荐指数
1
解决办法
3757
查看次数

RadiobuttonList的Bootstrap CSS

Radion按钮:

   <div class="control-group">
    <label class="control-label">Mode</label>
    <div class="controls">
        <asp:radiobuttonlist id="RadioButtonList1" cssclass="radio" autopostback="true" title="Please Select Mode of Payment"
          repeatdirection="Horizontal"
          onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
            <asp:listitem>Cash</asp:listitem>
            <asp:listitem>Cheque</asp:listitem>
            <asp:listitem>Demand Draft</asp:listitem>
            <asp:listitem>Net Banking</asp:listitem>
        </asp:radiobuttonlist>
    </div>
   </div>
Run Code Online (Sandbox Code Playgroud)

我已经应用了Bootstrap css:

  • 文本框,
  • 下拉列表,
  • textarea的,
  • 丁等

一切看起来很好,除了radiobutton列表,看起来很可怕:

在此输入图像描述

怎么解决这个?

css asp.net twitter-bootstrap

5
推荐指数
2
解决办法
3万
查看次数

无法使用C#在txt文件上写入文本

我试图在文本文件上写一个字符串,但它没有写任何东西,没有例外.我的代码是:

 public void CreateLog(string sLogInfo)
 {
    string sDestionation = null;

    string sFileName = DateTime.Now.ToString("yyyyMMdd") + "_log.txt";
    sDestionation = @"D:\Log\";
    //sDestionation = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + ConfigurationManager.AppSettings["DestinationPath"].ToString();
    string sFile = sDestionation + sFileName;

    if (!System.IO.Directory.Exists(sDestionation))
    {
       System.IO.Directory.CreateDirectory(sDestionation);
    }
    StreamWriter oWriter = null;
    if (!System.IO.File.Exists(sFile))
    {
       oWriter = File.CreateText(sFile);
    }
    else
    {
       oWriter = File.AppendText(sFile);
    }
    oWriter.WriteLine(DateTime.Now.ToString() + ": " + sLogInfo.Trim());
 }
Run Code Online (Sandbox Code Playgroud)

c# winforms

4
推荐指数
1
解决办法
175
查看次数

如何在signalR中的OnDisconnected事件中停止计时器

PushNotificationData客户端请求以方法建立集线器连接时,我启动了一个计时器。

根据计时器间隔,它确实从数据库中获取记录并推送到客户端。但是当客户端断开连接时,这个计时器必须停止而不是连续拉动。

所以我使用 OnDisconnected 事件来停止计时器。但不幸的是计时器没有停止

这是我的代码:

public class NotifyHub : Hub
{
    private string ConnectionId;
    private int UserId;
    private int UserTypeId;

    Timer timer = new Timer();

    public override Task OnConnected()
    {
        ConnectionId = Context.ConnectionId;
        return base.OnConnected();
    }
    public override Task OnDisconnected(bool stopCalled)
    {
        timer.Stop();
        timer.Enabled = false;
        //logic code removed for brevity
        return base.OnDisconnected(stopCalled);
    }
    public void PushNotificationData(Int32 userId, Int16 userTypeId)
    {

        UserId = userId;
        UserTypeId = userTypeId;
        ConnectionId = Context.ConnectionId;

        timer.Elapsed += Timer_Elapsed1;
        timer.Interval = 6000;
        timer.Enabled …
Run Code Online (Sandbox Code Playgroud)

c# asp.net timer signalr

2
推荐指数
1
解决办法
617
查看次数

无法将类型'System.Collections.Generic.List <MODEL#1>'隐式转换为'System.Collections.Generic.List <Model#2>

我正在使用MVC5和EF6.我得到以下转换错误

无法隐式转换 System.Collections.Generic.List<TreaceabilitySystem.GLB_M_PROFITCENTER>System.Collections.Generic.List<TreaceabilitySystem.Models.Profitcenter>

        private TSEntities db = new TSEntities();
        // GET: Profitcenter
        public ActionResult Index()
        {

            List<Profitcenter> profitcenter = new List<Profitcenter>();
Run Code Online (Sandbox Code Playgroud)
            profitcenter = db.GLB_M_PROFITCENTER.ToList(); //Error coming up here
Run Code Online (Sandbox Code Playgroud)
            return View(profitcenter.ToList());
        }
Run Code Online (Sandbox Code Playgroud)

我的模型在这里:当我在.edmx中添加表时,通过EF创建此模型

 public partial class GLB_M_PROFITCENTER
        {
            [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
            public GLB_M_PROFITCENTER()
            {
                this.GLB_M_USERMASTER = new HashSet<GLB_M_USERMASTER>();
            }

            public string PROFITCENTER_CODE { get; set; }
            public string PROFITCENTER_NAME { get; set; }
            public string DESCRIPTION { get; set; }
            public bool ISACTIVE { get; set; }
            public int CREATEDBY …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc entity-framework

1
推荐指数
1
解决办法
1684
查看次数

从网络驱动器中删除文件的批处理文件命令

我正在尝试定期从共享驱动器中删除应用程序日志,

ForFiles /p "\\netapp-1\Transfers\Logs\QA" /s /d -15 /c "cmd /c del @file"
Run Code Online (Sandbox Code Playgroud)

当路径是我的本地驱动器时,上述命令有效,但不适用于共享驱动器,任何帮助将不胜感激。

干杯!

windows cmd unc batch-file

1
推荐指数
1
解决办法
6879
查看次数

文本框更改事件无效

我有两个文本框,我正在尝试填充Textbox1的更改事件中的第二个文本框

例如:当我在TextBox1输入客户代码时,我必须填写客户名称.

我的剧本:

 $(document).ready(function() {

        userCodeChangeEvent();

    });


function userCodeChangeEvent() {

    $('#<%=txtCustomerCode.ClientID %>').change(function() {

        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "Customer_Bill.aspx/GetNameByCode",
            data: "{'CusName':'" + document.getElementById('<%=txtCustomerCode.ClientID %>').value + "'}",
            dataType: "json",
            success: function(data) {

                $('#<%=txtcustomerName.ClientID %>').value = data.d; 

            },
            error: function(result) {
                alert("No Match");
            }
        });


    });
}
Run Code Online (Sandbox Code Playgroud)

C#:

[WebMethod]
public static string GetNameByCode(string CusName)
{
   // List<string> empResult = new List<string>();
    string empResult = "";
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Constring"].ConnectionString))
    {
        using (SqlCommand cmd = new SqlCommand())
        {
            cmd.CommandText …
Run Code Online (Sandbox Code Playgroud)

c# sql-server asp.net jquery json

0
推荐指数
1
解决办法
143
查看次数