小编Onl*_*ere的帖子

为什么我找不到RadioButtonFor方法?

这是我的静态类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Linq.Expressions;
using System.Text;
using System.Web;

namespace Foo.WebUI.Infrastructure
{
    public static class HtmlHelpers
    {
        public static MvcHtmlString Image(this HtmlHelper helper, string src, string altText)
        {
            var builder = new TagBuilder("img");
            builder.MergeAttribute("src", src);
            builder.MergeAttribute("alt", altText);

            return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
        }

        public static MvcHtmlString RadioButtonForEnum<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
        {
            var metaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
            var names = Enum.GetNames(metaData.ModelType);
            var sb = new StringBuilder();
            foreach (var name in names)
            {
                var id = …
Run Code Online (Sandbox Code Playgroud)

c# using asp.net-mvc-3

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

如何从Cell_Leave事件中获取DataGridViewCell的值?

private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
    if (e.ColumnIndex > 1)
    {
        int cellValue = Convert.ToInt32(((DataGridViewCell)sender).Value);

        if (cellValue < 20)
        {
            ((DataGridViewCell)sender).Value = 21;
        }   
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试获取事件触发的单元格的值.

当我尝试强制sender转换为DataGridViewCell:

无法将类型为"System.Windows.Forms.DataGridView"的对象强制转换为"System.Windows.Forms.DataGridViewCell".

你推荐我做什么?

我需要检查值是否小于20,如果是,则将其提高到21.

c# int datagridview winforms

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

WPF图像拉伸填充不会延伸到它的父母的范围

这是我的XAML以及它的样子:

<Window x:Class="GameLenseWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="450" Width="350" MinHeight="450" MinWidth="350">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.15*" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Image Grid.Row="0" Stretch="Fill" Source="Image/topBarBg.png" />
        <StackPanel Orientation="Horizontal" Grid.Row="0">
            <TextBlock Text="Platform" 
                       Foreground="White" 
                       FontFamily="Georgia"
                       FontSize="15" 
                       Margin="10"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"/>
            <ComboBox x:Name="cmbPlatform" 
                      Margin="10"
                      FontFamily="Georgia"
                      FontSize="15"
                      MinHeight="30"
                      MinWidth="140"
                      VerticalAlignment="Center"
                      VerticalContentAlignment="Center" SelectionChanged="cmbPlatform_SelectionChanged">
                <ComboBoxItem>All Platforms</ComboBoxItem>
                <ComboBoxItem>Playstation 3</ComboBoxItem>
                <ComboBoxItem>XBox 360</ComboBoxItem>
                <ComboBoxItem>Wii</ComboBoxItem>
                <ComboBoxItem>PSP</ComboBoxItem>
                <ComboBoxItem>DS</ComboBoxItem>
            </ComboBox>
        </StackPanel>
        <Image x:Name="imgAbout" Grid.Row="0" Source="Image/about.png" 
               Height="16" HorizontalAlignment="Right"
               VerticalAlignment="Center"
               Margin="0 0 10 0"    />
        <ListBox Grid.Row="1" x:Name="lstGames" Background="#343434" Padding="5"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 HorizontalContentAlignment="Stretch">
            <ListBox.Resources>
                <Style TargetType="ListBoxItem">
                    <Style.Resources>
                        <!-- SelectedItem …
Run Code Online (Sandbox Code Playgroud)

wpf xaml image

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

什么是伪元素?

我正在剖析这个非常漂亮的例子,说明CSS如何帮助你在图像上创建漂亮的发光效果.

http://jsfiddle.net/necolas/KbNq7/

该示例中的这一特定行提到:

尽管此方法仅在Firefox 4中产生完整效果,但其他浏览器最终会赶上并将转换应用于 伪元素.

什么是伪元素?

html css pseudo-element

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

登录用户会在一段时间后退出

我制作了一个新的MVC3应用程序,它托管在WinHost的基本计划中.

问题的关键是,达到应用程序池内存限制并且每个会话InProc都被删除,这意味着我的用户已注销.

根据他们的文档,我看到:

http://support.winhost.com/KB/a626/how-to-enable-aspnet-sql-server-session-on-your-web.aspx

按照上面列出的步骤后,我的web.config的内容如下:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->
<configuration>  
  <connectionStrings>    
    <!-- REMOVED FOR PRIVACY -->
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>
  <system.web>    
    <sessionState mode="SQLServer"
                  allowCustomSqlDatabase="true"                  
                  cookieless="false"
                  timeout="2880"
                  sqlConnectionString="data Source='tcp:s407.winhost.com';database='DB_41_xx';user id='DB_11_xx_user'; password='xx';" />
    <trust level="Full"/>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.WebPages, …
Run Code Online (Sandbox Code Playgroud)

c# session web-config sql-server-2008 asp.net-mvc-3

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

这个C#动作方法代码是否实际触发301重定向?

以下是有人访问我的电子商务网站上的产品页面时使用的代码.

public ActionResult Details(int id, string slug)
{
    using (var productRepository = new EfProductRepository())
    {
        var product = productRepository.FindById(id);
        if (product == null) return RedirectToAction("Index", "Home");
        if (product.SeoTextSlug != slug)
            return RedirectToAction("Details", new {id = product.ProductId, slug = product.SeoTextSlug});

        var model = new ProductDetailModel();

        //Load the product information.
        model.Product.ProductId = product.ProductId;
        model.Product.CoverImagePath = product.CoverImagePath;
        model.Product.Name = product.Name;
        model.Product.Tagline = product.Tagline;
        model.Product.Price = product.Price;
        model.Product.Stock = product.Stock;
        model.Product.PieceCount = (int)product.PieceCount;
        model.Product.SKU = product.SKU;

        //Load the reviews for that product.
        if (product.Reviews.Any()) …
Run Code Online (Sandbox Code Playgroud)

c# redirect actionmethod http-status-code-301 asp.net-mvc-3

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

1gb数据库中可以有多少条记录/表?

我正在考虑购买共享托管服务提供商,然后提供1GB的MSSQL数据库.

这可能不是一门精确的科学,但我可以在1GB的数据库中保存多少条记录/表格?我将保存纯文本(意思是:nvarchar,varchar,int,bool)而不是二进制文件/ blob.

对于这个问题,想象一下大约20个表,每个表有9个字段.每个字段都不为空.

在我需要升级到更昂贵的软件包之前,是否有某种方法可以衡量和预测这将阻碍我多长时间?

sql-server record

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

当用户点击小键盘Enter键时,如何发送单个Downkey键?

这纯粹是出于我的客户问我的可用性要求.

他们使用datagridview为学生输入成绩.因此他们几乎进入了僵尸模式并开始使用数字,他们告诉我,如果他们可以点击小键盘输入键以使下一个垂直选择集中,那将会更容易.

这是我尝试使用的内容:

private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        SendKeys.Send("{DOWN}");
    }
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,它没有按预期工作.有时它似乎会多次触发该键,导致焦点向下滚动2或3或4个单元并真正震动用户的焦点.

我怎样才能做到这一点,让我的客户满意?

.net c# datagridview key winforms

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

即使密码相同,比较验证器也始终触发

这就是原因所在.这是生成的HTML:

    <div>
        <label for="RegisterModel_Password">Contrase&#241;a</label>
        <input class="text-box single-line password" data-val="true" data-val-length="Su Contrase&amp;#241;a debe tener al menos 6 caracteres." data-val-length-max="100" data-val-length-min="6" data-val-required="Debe escribir su contrase&amp;#241;a" id="RegisterModel_Password" name="RegisterModel.Password" type="password" value="" />
        <span class="field-validation-valid" data-valmsg-for="RegisterModel.Password" data-valmsg-replace="true"></span>

    </div>

    <div>
        <label for="RegisterModel_ConfirmPassword">Confirme Su Contrase&#241;a</label>
        <input class="text-box single-line password" data-val="true" data-val-equalto="Sus contrase&amp;#241;as no son las mismas." data-val-equalto-other="*.Password" id="RegisterModel_ConfirmPassword" name="RegisterModel.ConfirmPassword" type="password" value="" />
        <span class="field-validation-valid" data-valmsg-for="RegisterModel.ConfirmPassword" data-valmsg-replace="true"></span>
    </div>
Run Code Online (Sandbox Code Playgroud)

请注意,在确认密码框中:

data-val-equalto-other="*.Password"
Run Code Online (Sandbox Code Playgroud)

这应该是RegisterModel.Password,因为我猜测javascript看起来像名为"RegisterModel.Password"的输入,不是吗?

这是我的型号代码:

[Required(ErrorMessage = "Debe escribir su contraseña")]
[StringLength(100, ErrorMessage = "Su {0} debe tener al …
Run Code Online (Sandbox Code Playgroud)

unobtrusive-javascript asp.net-mvc-3

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

Javascript值不显示小数,除非它不是0.00

//Value being parsed at this point is "150.00"
var productValue = parseFloat($("#product-cost-value-value").text().replace(',', '.'));    

console.log(productValue);
Run Code Online (Sandbox Code Playgroud)

记录的值是150.

但是如果我给它添加一些值,就像这样.该值将更改为显示我想要的两位小数.

console.log(productValue + 0.01);
Run Code Online (Sandbox Code Playgroud)

记录的值是 150.01

如何强制我的值始终显示两位小数?

javascript floating-point

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