我需要用来Server.MapPath()组合我存储在的一些文件路径web.config.
但是,由于Server.MapPath()依赖于当前的HttpContext(我认为),我无法做到这一点.在尝试使用该方法时,即使它"可用",我也会遇到以下异常:
在此上下文中无法使用服务器操作.
是否有另一种方法可以将Web根目录相对目录映射~/App_Data/到完整的物理路径,例如C:\inetpub\wwwroot\project\App_data\?
我有一个C#.Net网络应用程序.在该应用程序中,我需要根据登录系统的人有条件地禁用Html.TextBoxFor控件(也包括Html.DropDownListFor控件).我试过用
@Html.TextBoxFor(model => model.ProposalName, new { @ViewBag.IsDisabled })
Run Code Online (Sandbox Code Playgroud)
在Controller中@ViewBag.IsDisabled设置为String.Empty或"disabled"的位置.然而,这呈现为IsDisabled='disabled'或IsDisabled=""因此控制没有被禁用.当我尝试
@Html.TextBoxFor(model => model.ProposalName, new { @ViewBag.Disabled })
Run Code Online (Sandbox Code Playgroud)
即使不ViewBag.Disabled包含文本,控件也始终处于禁用状态.如何有条件地禁用Html.TextBoxFor()控件?
我有一个像以下网站项目:
namespace Web
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lbResult.Text = PathTest.GetBasePath();
}
}
}
Run Code Online (Sandbox Code Playgroud)
该方法PathTest.GetBasePath()在另一个项目中定义,如:
namespace TestProject
{
public class PathTest
{
public static string GetBasePath()
{
return AppDomain.CurrentDomain.BaseDirectory;
}
}
}
Run Code Online (Sandbox Code Playgroud)
为什么...\Web\在将TestProject程序集编译到bin文件夹时显示它(换句话说,它应该显示...\Web\bin在我的想法中).
如果我修改了方法,我现在遇到了麻烦:
namespace TestProject
{
public class FileReader
{
private const string m_filePath = @"\File.config";
public static string Read()
{
FileStream fs = null;
fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + m_filePath,FileMode.Open, …Run Code Online (Sandbox Code Playgroud) 我有一个ASP.NET MVC 3应用程序JQuery UI Tabs.我有一个主布局页面_layout.cshtml,代码如下.主人_layout.cshtml需要一个@RenderBody()代码.因为它是必需的,我应该怎么做.我猜我要去的地方是我不知道我是否正确这样做,因为我没有使用它.
如果不是,我应该是什么问题?
谢谢.
<div class="page">
<div id="title" style=" height:120px" >
<img alt="Test.com" src="/Content/images/TestLogoLeft.png" style="width:370px; float:left; margin:0px;" />
</div>
<div id="titleRight" style=" background-color:White; width:580px; height:120px; float:right;"></div>
<div id="menu" style=" background-color:White; width:950px; height:400px; float:left;">
<!-- Must have class= info to prevent flash of just content on refresh -->
<div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all" style=" position:relative; border:0px;" >
<ul class="ui-tabs-nav">
<li><a href="#tabs-1" >Home</a></li>
<li><a href="#tabs-2" >Statistics</a></li>
<li><a href="#tabs-3" >Maps</a></li>
<li><a …Run Code Online (Sandbox Code Playgroud) 我的桌面是win7,我正在尝试连接到服务器2012.
两个主机都在同一个域上.
如果我做:
Enter-PSSession -ComputerName *ServerName***
Run Code Online (Sandbox Code Playgroud)
我从winrm收到以下失败消息
Enter-PSSession:连接到远程服务器xxx失败,并显示以下错误消息:WinRM无法处理请求.使用Kerberos身份验证时发生以下错误:找不到计算机xxx.验证网络上是否存在计算机,并且提供的名称拼写正确.*
如果我只使用服务器名称或完全符合条件输入它并不重要.
两个系统都表明了 $PSVersionTable.PSVersion 4 0 -1 -1
我已经尝试了各种故障排除提示,我发现即
运行Enable-PSRemoting -Force,也设置TrustedHosts = *在两侧.
我还禁用了双方的防火墙服务.
当我尝试从服务器将Enter-PSSession输入到我的桌面时,它可以根据需要运行.
但是从我的桌面到服务器,我总是收到无法找到计算机的错误消息.
我得到以下错误:
执行处理程序的子请求时出错,
System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper
在线
<li>@{Html.RenderAction("CartSummary", "ShoppingCart");}</li>
Run Code Online (Sandbox Code Playgroud)
以上代码在 Shared/_Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")"
rel="stylesheet"
type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")"
type="text/javascript"></script>
</head>
<body>
<div id="header">
<h1><a href="/">ASP.NET MVC MUSIC
STORE</a></h1>
<ul id="navlist">
<li class="first">
<a href="@Url.Content("~")" id="current">
Home</a></li>
<li><a href="@Url.Content("~/Store/")">Store</a></li>
<li>@{Html.RenderAction("CartSummary", "ShoppingCart");}</li>
<li><a href="@Url.Content("~/StoreManager/")">
Admin</a></li>
</ul>
</div>
@{Html.RenderAction("GenreMenu", "Store");}
<div id="main">
@RenderBody()
</div>
<div id="footer">
built with <a href="http://asp.net/mvc">ASP.NET MVC 3</a>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
CartSummary 行动:
/ GET: /ShoppingCart/CartSummary
[ChildActionOnly]
public ActionResult CartSummary()
{
var cart = ShoppingCart.GetCart(this.HttpContext); …Run Code Online (Sandbox Code Playgroud) 什么是处理错误的最佳方法,例如
从客户端检测到一个潜在危险的Request.Form值"
在ASP.NET中?
我想保持验证,因为我的表单没有正当理由允许HTML字符.但是,我不太确定如何以更友好的方式处理此错误.我尝试在一个处理它,Page_Error但据我所知,这发生在较低级别的部分,所以该Page_Error功能永远不会触发.
因此,我可能不得不求助于Application_Error在我的Global.asax文件中使用.如果这是处理该错误的唯一方法,有没有办法专门处理这个错误?我不想以同样的方式处理所有应用程序错误.
谢谢
我正在尝试模拟Bootstrap崩溃标题上的clik,但没有成功.
我真正想要做的是,当用户点击手风琴标题附近的图像时,它会打开,就像用户点击<a>了标题一样.
这是一个更好理解的FIDDLE
我的HTML标记如下所示:
<div class="accordion" id="accordionFilter">
<div class="accordion-group">
<div class="accordion-heading">
<img src="http://placehold.it/40x40" onclick="SimulateClick();">
<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordionFilter" href="#collapseOne">
Filter the results
</a>
</div>
<div id="collapseOne" class="accordion-body collapse">
<div class="accordion-inner">
<div class="row">
<br>
<div class="col-lg-3 col-md-3 col-sm-3">
1st column content
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
2nd column content
</div>
</div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
但我不知道如何在SimulateClick()JS方法中写"点击图像,打开手风琴" .
我尝试过类似的东西
$("#collapseOne").click();
Run Code Online (Sandbox Code Playgroud)
要么
$("#collapseOne").addClass("in");
Run Code Online (Sandbox Code Playgroud)
但它没有做任何事情.
任何的想法 ?
我正在从表中读取字符串ID值.当ID是由用户输入的,它是与所述用户定义的输入掩码完成的,所以掩模本来类似000-00-0000,##-######,AA-9999999等掩模将由使用者而变化,所以必须在运行时评估.
假设表中只存储了字母数字文本,那么应用该掩码生成新字符串的最佳方法是什么?
例如:
表值="123456789"
如果用户定义了掩码000-00-0000,我想得到字符串123-45-6789.
如果用户定义了掩码AA-9999999,我想得到字符串12-3456789.
如果用户定义了掩码FR999_999999,我想得到字符串FR123_456789.
这个问题没有完全回答,请免费提供!
我正在尝试在progress bar提交大型表单时显示简单的内容.
该表单包含十几个字段,以及一些文件上载字段,用户可以在其中选择图片.然后,当他点击Create按钮时,将提交包含数据和图片的表单,并在DB中创建实体.(只需点击一下即可提交表格和图片).
一切正常,但我想在提交过程中显示进度条.
我找到了很多解释如何显示进度条的教程,但我没有找到任何人解释如何显示进度条,表明方法完成的工作百分比,即我希望看到10%, 25%等...在提交过程中.
所以,基本上,这就是我所做的:(这是一个ASP.NET MVC3项目)
@model MyModel
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "target-form", enctype = "multipart/form-data" }))
{
//some Html.TextBoxFor() and other @Html.DropDownListFor
@Html.TextBoxFor(m => m.File, new { type = "file"})
<input type="submit" value="Create" class="submitButton" />
<div id="progressBar"></div>
}
Run Code Online (Sandbox Code Playgroud)
和一个基本的控制器
[HttpPost]
public ActionResult Create(MyModel model)
{
if (ModelState.IsValid)
{
DALLayer dal = new DALLayer()
dal.AddEntity(model);
return RedirectToAction("Index", "Home");
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
是否有可能<div>在 …
asp.net ×5
c# ×3
jquery ×3
javascript ×2
.net-3.5 ×1
accordion ×1
asp.net-mvc ×1
collapse ×1
conditional ×1
global-asax ×1
html.textbox ×1
progress ×1
progress-bar ×1