小编Ron*_*ald的帖子

从Asp.net ListBox中删除所选项目

我需要从asp.net中的ListBox中删除所选项.我一直在寻找Windows窗体的示例,但不是asp.net.

我有一个按钮单击事件,将所有项目从一个列表框复制到另一个列表框.我希望能够从第二个列表框中选择单个项目,然后单击按钮将其删除.

protected void btnAddAllProjects_Click(object sender, EventArgs e)
{

    foreach (ListItem item in lstbxFromUserProjects.Items)
    {
        lstBoxToUserProjects.Items.Add(item.ToString());
    }


}

    protected void btnRemoveSelected_Click(object sender, EventArgs e)
    {}
Run Code Online (Sandbox Code Playgroud)

c# asp.net listbox

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

查找具有两个指定列名的SQL Server表

我想在sql server中搜索一个表有两个特定列名ex(columnA和columnB)的表.我有一个查询一个列名称的查询

SELECT name FROM sysobjects WHERE id IN 
( SELECT id FROM syscolumns WHERE name = 'columnA' )
Run Code Online (Sandbox Code Playgroud)

我不知道如何修改它来搜索两列.

t-sql sql-server

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

将DTO转移到ViewModel

这是我的数据传输对象

public class LoadSourceDetail
{
  public string LoadSourceCode { get; set; }
  public string LoadSourceDesc { get; set; }
  public IEnumerable<ReportingEntityDetail> ReportingEntity { get; set; }
}

public class ReportingEntityDetail
{
  public string ReportingEntityCode { get; set; }
  public string ReportingEntityDesc { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

这是我的ViewModel

public class LoadSourceViewModel
{
    #region Construction

        public LoadSourceViewModel ()
        {
        }

        public LoadSourceViewModel(LoadSourceDetail data)
        {
            if (data != null)
            {
                LoadSourceCode = data.LoadSourceCode;
                LoadSourceDesc = data.LoadSourceDesc;
                ReportingEntity = // <-- ?  not sure …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc asp.net-mvc-3 asp.net-mvc-4

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

OnClientClick代码阻止验证工作

我已经在asp.net按钮的OnClientClick属性中添加了代码,现在验证控件无法正常工作.当我删除OnClientClick代码时,验证工作.

我怎样才能使它们都起作用?

<asp:Button 
ID="btnNext" 
runat="server" 
Text="Save & Continue" 
SkinID="btnContinue" 
OnClick="btnNext_Click"  
OnClientClick="_changesMade=false; return true;" 
ValidationGroup="vgPreMedSchool" Width="176px" />
Run Code Online (Sandbox Code Playgroud)

javascript c# asp.net jquery

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

阻止不可见标签占用空间

有没有办法停止占用表单空间不可见的标签控件?

asp.net

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

Convert.ToString不处理null

我已经读过Convert.ToString应该处理null,但是当它在我的代码中传递一个null对象时它不起作用

在这种情况下,对象"Name"为null.

var name = Convert.ToString(Name.LastName);
Run Code Online (Sandbox Code Playgroud)

我没有将Object引用设置为对象的实例.

c# asp.net

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

获取MVC3中复选框的值

我在页面上有一些html复选框,我需要验证他们是否已检查页面的回发事件.

这些复选框的数据不存储在数据库中,只需在使用之前进行检查即可进入下一页.

我如何验证它们已被检查?我在Request.Form.AllKeys集合中看不到它们

<input id='terms_eligibility' type='checkbox'   />
<input id='terms_accurate' type='checkbox' />
<input id='terms_score_release' type='checkbox' />
Run Code Online (Sandbox Code Playgroud)

编辑这是我最终做的

视图

 @Html.CheckBox("terms_eligibility")
Run Code Online (Sandbox Code Playgroud)

调节器

string eligibility = Request.Form.GetValues("terms_eligibility")[0];
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc asp.net-mvc-partialview asp.net-mvc-3

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

清除为可空布尔值编写代码的方法

是否有更简洁的方法来编写此代码.我感觉可能有,但我不知道如何.

    if (loadedFormData.Education.AwardedADegree==true)
    {
        this.radiobuttonNoAwarded.Checked = false;
        this.radiobuttonYesAwarded.Checked = true;
    }
    if (loadedFormData.Education.AwardedADegree == false)
    {
        this.radiobuttonNoAwarded.Checked = true;
        this.radiobuttonYesAwarded.Checked = false;
    }
    else // AwardedADegree is null
    {
        this.radiobuttonNoAwarded.Checked = false;
        this.radiobuttonYesAwarded.Checked = false;

    }
Run Code Online (Sandbox Code Playgroud)

c# asp.net nullable

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

从链接中删除下划线和蓝色

我正在尝试禁用两个锚标签,我无法删除下划线.我也想删除蓝色.这就是我所拥有的并不是删除下划线.我试过将文本装饰设置为nonenone !important

        $(document).ready(function ()
        {
            // See if doc upload View and Remove panel is displayed --> do they currently have a document uploaded 
            var isInline = $("#ctl00_contentMain_pnlAuthorizationForReleaseViewUploadDocument").css('display');

            // if so disable upload and electronic sig links
            if (isInline == "inline")
            {
                //Disable Upload Link after document is uploaded
                $("#ctl00_contentMain_btnUpload").attr('onclick', '').click(function (e) {
                    e.preventDefault();
                });
                $("#ctl00_contentMain_btnUpload").attr('href', '');
                $("#ctl00_contentMain_btnUpload").attr('text-decoration', 'none !important');

                //Disable Electronic Sign Link after document is uploaded
                $("#ctl00_contentMain_lnkESign").attr('onclick', '').click(function (e) {
                    e.preventDefault();
                });
                $("#ctl00_contentMain_lnkESign").attr('href', '');
                $("#ctl00_contentMain_lnkESign").attr('text-decoration', …
Run Code Online (Sandbox Code Playgroud)

html asp.net jquery

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

将值从隐藏字段传递到 ActionLink,然后传递到 Controller

我试图通过让用户选择他们想要的报告的复选框来动态设置 StudentId。当他们单击 ActionLink 时,我使用 jQuery 在隐藏字段中设置 id 的值。我需要操作链接来读取隐藏字段中的 id。

这些值在隐藏字段中设置,但它们没有从 actionLink 传递到控制器。

我需要将 ReportIds 传递给控制器​​。

        @Html.ActionLink("PrintMed", "GetMedEdVerificationReport", "Student", new { studentIdList = Model.ReportIds }, new { @class = "button print_selected print_selectedMedEd disabled" })



        @Html.HiddenFor(model => model.ReportIds)
Run Code Online (Sandbox Code Playgroud)

javascript

$('.print_selectedMedEd').bind('click', function () {
    var ids = getPrintIds();
    if (ids.length == 0) {
        return false;
    }

    $('#ReportIds').val(ids.toString());


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

c# asp.net asp.net-mvc razor asp.net-core

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

删除后MVC重新加载页面

我的删除方法正在运行,但您必须手动刷新浏览器才能看到它已被删除.我只是想重新加载页面,但我无法让它工作.有人能告诉我这样做的正确方法吗?

public virtual ActionResult Index()
{
    var recipientOrchestrator = new RecipientsOrchestrator();
    RecipientsViewModel model = recipientOrchestrator.GetRecipientsPageData();
    return View(model);
}


[HttpPost]
public virtual ActionResult Delete(int id, int applicationId) 
{
    var recipientOrchestrator = new RecipientsOrchestrator();
    recipientOrchestrator.DeleteRecipient(id, applicationId);

    return Index();

}
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc-4

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