小编Rai*_*ika的帖子

将事件添加到Jquery插件

我有一个JQuery插件,我想添加一些事件.任何帮助,提示或教程?

javascript jquery

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

在Razor中将日期转换为ToShortDateString

我有一个必须在编辑视图中显示的DateTime字段

@Html.EditorFor( model => model.StartDate )
Run Code Online (Sandbox Code Playgroud)

我怎么能用这样的东西;

@Html.EditorFor( model => model.StartDate.ToShortDateString() )
Run Code Online (Sandbox Code Playgroud)

或任何用于更改视图的DateTime的自定义函数.

razor

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

延迟加载是否可能在精致?通用(POCO)和动态API有什么区别?

关于使用小巧玲珑,我有两个问题:

  1. 有没有办法加载导航键属性,如实体框架(延迟加载)?

  2. POCO serialization和之间有什么区别dynamic serialization?哪个更好?以及如何使用此序列化?

c# dapper

11
推荐指数
2
解决办法
5838
查看次数

如何查找所有控制器和操作

如何在dotnet核心中查找其属性的所有控制器和操作?在.NET Framework中,我使用了以下代码:

public static List<string> GetControllerNames()
{
    List<string> controllerNames = new List<string>();
    GetSubClasses<Controller>().ForEach(type => controllerNames.Add(type.Name.Replace("Controller", "")));
    return controllerNames;
}
public static List<string> ActionNames(string controllerName)
{
    var types =
        from a in AppDomain.CurrentDomain.GetAssemblies()
        from t in a.GetTypes()
        where typeof(IController).IsAssignableFrom(t) &&
            string.Equals(controllerName + "Controller", t.Name, StringComparison.OrdinalIgnoreCase)
    select t;

    var controllerType = types.FirstOrDefault();

    if (controllerType == null)
    {
        return Enumerable.Empty<string>().ToList();
    }
    return new ReflectedControllerDescriptor(controllerType)
       .GetCanonicalActions().Select(x => x.ActionName).ToList();
}
Run Code Online (Sandbox Code Playgroud)

但它不适用于dotnet核心.

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

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

通过jQuery加载ascx

有没有办法通过jQuery加载ascx文件?

更新:

感谢@Emmett和@Yads.我正在使用带有以下jQuery ajax代码的处理程序:

 jQuery.ajax({
    type: "POST",  //GET
    url: "Foo.ashx",
    data: '{}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (response)
    {
        jQuery('#controlload').append(response.d); // or response
    },
    error: function ()
    {
        jQuery('#controlload').append('error');
    }
 });
Run Code Online (Sandbox Code Playgroud)

但是我收到了一个错误.我的代码错了吗?

另一个更新:我正在使用

error: function (xhr, ajaxOptions, thrownError)
{
    jQuery('#controlload').append(thrownError);
}
Run Code Online (Sandbox Code Playgroud)

这就是我得到的:

无效的JSON:
Test =>(此测试是我的ascx中的标签)

和错误后的我的ascx文件!

另一个更新:

我的ascx文件是这样的:

<asp:DropDownList ID="ddl" runat="server" AutoPostBack="true">
    <asp:ListItem>1</asp:ListItem>
    <asp:ListItem>2</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label1" runat="server">Test</asp:Label>
Run Code Online (Sandbox Code Playgroud)

但是当调用ajax我在asp中得到这个错误:(

必须将带有'DropDownList'类型的控件'ctl00_ddl'放在带有runat = server的表单标记内.

感谢@Yads.但他的解决方案只适用于html标签.

asp.net jquery webforms

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

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

替换Castle Windsor中的Obsolete AllTypes类

我有旧城堡的代码

IoC.Container.Register( 
    AllTypes
        .FromAssemblyNamed(a)
        .Pick().WithService.FirstInterface()
        .Configure(o => o.LifeStyle.PerWebRequest));
Run Code Online (Sandbox Code Playgroud)

当我升级到城堡3.2时,我收到此错误:

Castle.MicroKernel.Registration.AllTypes'已过时

o.LifeStyle.PerWebRequest的这个错误:

只有赋值,调用,递增,递减,等待和新对象表达式才能用作语句

我怎样才能解决这个问题?

castle-windsor

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

从asp.net中的代码编写Html标记

如果标题混乱,建议改变它

从代码中编写自己的HTML的最佳方法是什么?

我目前使用这个:

<asp:Literal ID="ltr" runat="server"></asp:Literal>
Run Code Online (Sandbox Code Playgroud)

并从代码背后:

ltr.Text = "<p class=\"specific-class\"></p>";
Run Code Online (Sandbox Code Playgroud)

做这样的事情是对的吗?

有一个更好的方法吗?

asp.net

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

使用不带身份的承载/ Jwt授权

我想开发一个Aspnet.IdentityIdentity和阅读一些文件Identity意识到我需要的DBContext.
搜索后,我找不到任何使用授权的文件或样本Aspnet.Identity.我有自己的会员资格,我不想使用Identity
我应该使用Identity图书馆吗?或者有没有办法在我的会员资格中实施授权.

一个小方问题:
如果我被迫使用身份如何更改DBContext为类似Aspnet.IdentityIdentity对我Identity

jwt asp.net-web-api asp.net-core

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

从DataGrid的DataGridTemplateColumn获取Checkbox值

我有这个XAML

<DataGrid Name="grdData" ... >
   <DataGrid.Columns>
      <DataGridTemplateColumn Header="Something">
         <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
               <CheckBox Name="chb" />
            </DataTemplate>
         </DataGridTemplateColumn.CellTemplate>
       </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)

我尝试使用此代码获取Checked State

for( int i = 0 ; i < grdData.Items.Count ; i++ )
{
    DataGridRow row = ( DataGridRow )grdData.ItemContainerGenerator.ContainerFromIndex( i );
    var cellContent = grdData.Columns[ 1 ].GetCellContent( row ) as CheckBox;
    if( cellContent != null && cellContent.IsChecked == true )
    {
       //some code
    }
}
Run Code Online (Sandbox Code Playgroud)

我的代码错了?

c# wpf

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