小编Dav*_*Dev的帖子

ASP.net MVC3 - 具有Ajax回发的Razor视图和PartialViews

让我的工作变得非常失败!

在一个视图中......

@model Project.Models.Account.ForgotPasswordModel

@{
    ViewBag.Title = "Forgot Password";
}

<h2>ForgotPassword</h2>

<span id='@ViewBag.ReplaceID'>
    @Html.Partial("_ForgotPasswordUserNameAjax", ViewData.Model)
</span>
Run Code Online (Sandbox Code Playgroud)

我渲染这个partialView ...

@model Project.Models.Account.ForgotPasswordModel

@{
    this.Layout = null;
}

@using (Ajax.BeginForm("ForgotPassword", new AjaxOptions() { UpdateTargetId = ViewBag.ReplaceID, InsertionMode = InsertionMode.InsertAfter }))
{
    @Html.ValidationSummary(true, "Forgot Password was unsuccessful. Please correct the errors and try again.")
    <div id="login" class="box">
            <fieldset>
            <h2>Account Information</h2>
            <div class="inside">
                <div class="editor-label">
                    @Html.LabelFor(m => m.Username)
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.Username)
                    <br />
                    @Html.ValidationMessageFor(m => m.Username)
                    <br />
                </div>

                <p>
                    <input type="submit" …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc razor asp.net-mvc-3

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

Objective-C将整数转换为十六进制值

我有一个像这样初始化的字典......

keyDictionary = [[NSDictionary dictionaryWithObjects:values forKeys:keys]retain];
Run Code Online (Sandbox Code Playgroud)

其中keysNSArray字母和其他字符values的一个NSArray,是unsigned chars的一个,它们是这些字符的USB十六进制密钥代码.

USB密钥代码是十六进制值,范围从0x04到0xE7.我正在尝试根据键盘上按下的键创建这两者之间的地图.

这个values数组是这样创建的......

NSArray *values = [NSArray arrayWithObjects: 
                  [NSNumber numberWithUnsignedChar:0x04]/*A*/,
                  [NSNumber numberWithUnsignedChar:0x05]/*B*/, /*ETC*/]; 
Run Code Online (Sandbox Code Playgroud)

理想情况下,当我运行此代码时...在哪里 character == @"I"

- (uint8) getUSBCode:(NSString *)character
{
    NSNumber *val = [keyDictionary objectForKey:character];

    return (uint8)[val unsignedCharValue];
}
Run Code Online (Sandbox Code Playgroud)

我希望能够回来0x0C,但是我作为一个int得到12回归(在我想到之后,这是有道理的).我需要保留十六进制值.我不需要字符串值.我需要直接转换为十六进制值或更好的存储方式

uint8 只是一个typedef unsigned char.

编辑 我之前发布时并不清楚.这就是我需要的.

我需要这些代码的十六进制值,因为它们是通过内部公司网络发送的.此外,按下的键的值正在从big endian(或者很少,它正在逃避我现在的哪一个)转换到另一个,然后通过内部网络传输.我知道这些值存储在二进制文件中,但我需要以十六进制格式传输它们.

另外,我说我从这个功能回来了12.我从调试器中读到12,实际上没有得到这个值.这可能就是我迷茫的原因.

objective-c nsnumber

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

添加minizip break Objective-C

我试图在WikiPage之后将ZipArchive添加到我的项目中.我已将它添加到我的项目并尝试构建,但现在NSObjRuntime.h,NSObject.h和无数其他头文件都有解析问题!

我已经包含了我工作区的截图

工作区

和错误......

错误

关于该项目的更多细节.

  • 针对iOS5构建.
  • 使用ARC.

xcode objective-c

8
推荐指数
2
解决办法
2963
查看次数

UIPageViewController手势正在调用viewControllerAfter:但是没有动画

我对UIPageViewController有一个非常有趣的问题.

我的项目设置与示例基于页面的应用程序模板非常相似.偶尔(但在某种程度上可重现)某个平移手势会呼唤-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController.

我返回下一页的viewcontroller,但是从不运行页面翻转动画,我的委托方法永远不会被调用.

这是代码 viewControllerAfterViewController

-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
    PageDisplayViewController *vc = (PageDisplayViewController *)viewController;
    NSUInteger index = [self.pageFetchController.fetchedObjects indexOfObject:vc.page];
    if(index == (self.pageFetchController.fetchedObjects.count - 1)) return nil;
    return [self getViewControllerForIndex:(++index)];
}
Run Code Online (Sandbox Code Playgroud)

这里是 getViewControllerForIndex:

-(PageDisplayViewController *)getViewControllerForIndex:(NSUInteger)index
{
    PageDisplayViewController *newVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PageDisplayController"];
    newVC.page = [self.pageFetchController.fetchedObjects objectAtIndex:(index)];
    newVC.view.frame = CGRectMake(0, 0, 1024, 604);
    NSLog(@"%i", index);
    if(index == 0)
    {
        //We're moving to the first, animate the back button to be hidden.
        [UIView animateWithDuration:0.5 animations:^
        { …
Run Code Online (Sandbox Code Playgroud)

ios uipageviewcontroller

8
推荐指数
2
解决办法
8701
查看次数

使用EF6查询多对多的性能

我们遇到了一个性能问题,其查询使用了与单个表格的几个M:M关系.

表:

架构

目前,EF生成一个MONSTROUS查询,该查询对Contact表使用UNION ALL 3次. 每次连接都有一次SQL的Pastebin.我们的预测是这样的

var contacts = query.Select(contact => new Contact
            {
                Brands = contact.Brands.Select(b => new Brand
                {
                    Id = b.Id,
                    Name = b.Name,
                    Aliases = b.Aliases.Select(a => a.Value).ToList()
                }).ToList(),
                Categories = contact.Categories.Select(category => new Category
                {
                    Id = category.Id
                }).ToList(),
                ContactTypes = contact.ContactTypes.Select(ct => new ContactType
                {
                    Id = ct.Id
                }).ToList(),
                Disabled = contact.Disabled,
                Email = contact.Email,
                Fax = contact.Fax,
                Id = contact.Id,
                Latitude = contact.Coordinates != null ? contact.Coordinates.Latitude : 0,
                Longitude = …
Run Code Online (Sandbox Code Playgroud)

entity-framework entity-framework-6

7
推荐指数
0
解决办法
147
查看次数

Asp.net MVC - 从区域渲染局部视图

我创建了一个区域,可以处理我们所有开发产品中的一些通用的东西,就像登录,HTML帮助器等.在该区域内,我有一个局部视图,我试图在该区域之外引用.我已经注册了该地区

public class Routes : AreaRegistration
{
    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Common_default",
            "Common/{controller}/{action}/{id}",
            new {
                controller = "Account",
                action = "Index",
                id = UrlParameter.Optional
            });
    }

    public override string AreaName
    {
        get { return "MvcCommons"; }
    }
}
Run Code Online (Sandbox Code Playgroud)

现在在常规项目中,我试图在MvcCommons区域中引用一个视图......

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>TestGrid</h2>

<% Html.RenderPartial("jQGridTable", ViewData.Model); %>
Run Code Online (Sandbox Code Playgroud)

但我一直认为没有找到视图.之前,在创建MVC Commons项目时,我收到了查看错误,但错误告诉我它在区域文件夹和默认视图文件夹中都有查看.这次,我只获取默认文件夹.有没有办法实现这个目标?

感谢大家!

c# asp.net-mvc renderpartial asp.net-mvc-areas

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

使用 Autofac 对委托工厂进行单元测试

我正在努力通过一些众多的 DI 框架来证明依赖注入的使用。我正在尝试对当前使用 Autofac 作为 DI 容器的一些类进行单元测试。

假设我有这门课...

public class SaveUserCommand : DBCommandBase<UserImpl>
{
    public delegate SaveUserCommand Factory(UserImpl impl);

    private UserImpl impl;
    private IAuditableHelper helper;

    public SaveUserCommand(UserImpl impl, IAuditableHelper helper)
    {
        this.impl = impl;
        this.helper = helper;
    }

    public override UserImpl Execute(object dataTrans)
    {
        return this.impl;
    }
}
Run Code Online (Sandbox Code Playgroud)

^命令结构化业务层顺便说一句。

我有另一个命令以这种方式依赖于上面的命令......

public class SaveSpecialUserCommand : DBCommandBase<UserImpl>
{
    public delegate SaveSpecialUserCommand Factory(UserImpl user);

    private UserImpl user;
    SaveUserCommand.Factory saveUserCommand;

    public SaveSpecialUserCommand(UserImpl user, SaveUserCommand.Factory saveUserCommand)
    {
        this.user = user;
        this.saveUserCommand = saveUserCommand;
    }

    public …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing autofac

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