我需要查看视图中可用的所有变量.我是一名前端开发人员,所以我主要在views目录中工作.我并不总是知道后端dev将哪些变量传递给模板.而不是每次问他一个简单的解决方案是什么类型的片段,我可以暂时粘贴到我正在处理的视图中,所以我可以看到所有可用的变量,甚至更好,如果我也可以看到他们的类型和值.
我试过这个:
<pre><?php var_dump(get_defined_vars()); ?></pre>
Run Code Online (Sandbox Code Playgroud)
但是由于我使用Codeigniter,它还显示了框架传递的所有其他吨和吨变量.
我只想显示从加载视图的控制器专门传递的变量.有没有办法做到这一点?
(对不起,这里有几个项目,但似乎没有一个允许我让这个工作.)
我想创建一个允许多选的DropDownList.我能够填充列表,但我无法获得当前选定的值似乎工作.
我的控制器中有以下内容:
ViewBag.PropertyGroups = from g in db.eFinGroups
where g.GroupType.Contents == "P"
select new
{
Key = g.Key,
Value = g.Description,
Selected = true
};
ViewBag.SelectedPropertyGroups = from g in company.Entities
.First().Properties.First().PropertyGroups
select new {
g.eFinGroup.Key,
Value = g.eFinGroup.Description };
在视图中我有:
@Html.DropDownListFor(model => model.PropertyGroupsX,
new MultiSelectList(ViewBag.PropertyGroups
, "Key", "Value"
, ViewBag.SelectedPropertyGroups),
new { @class = "chzn-select", data_placeholder = "Choose a Property Group", multiple = "multiple", style = "width:350px;" })
PropertyGroupX是模型中的字符串[].
我已尝试使用所选属性的所有类型的迭代...只传递值,只传递键,两者等.
另外,PropertyGroupX应该是什么类型的?字符串数组是否正确?或者它应该是包含当前属性组的字典?我真的很难找到这方面的文档.
有人建议我应该使用ListBoxFor.我已经改变了,仍然有同样的问题.呈现选项标记时,所选值未设置为选中状态.这是我尝试过的:
@ Html.ListBoxFor(model => model.PropertyGroups,new MultiSelectList(ViewBag.PropertyGroups,"Key","Value"))
我已经尝试将model.PropertyGroups作为匹配值的字符串集合,作为Guid的集合匹配此ID,并作为匿名类型同时具有Key和Value以匹配ViewBag中的项目.似乎没什么用.
selectlist multi-select asp.net-mvc-3 drop-down-menu html.listboxfor
我正在研究具有以下路由代码的symfony 2.3项目
just2_frontend_logincheck:
pattern: /login_check
Run Code Online (Sandbox Code Playgroud)
它没有
defaults:{ _controller: testBundle:User:login }
Run Code Online (Sandbox Code Playgroud)
但它正在发挥作用.但我不知道路由是如何工作的.可能吗?请告诉我有关路由的信息.
我在使用Asp.Net构建应用程序方面有一些经验,但现在MVC框架变得更受欢迎.我想尝试使用Asp.Net MVC或Castle MonoRail构建新的多语言Web应用程序,但我不知道哪一个对我有好处.我不喜欢Web表单视图引擎,但我喜欢Asp.Net MVC中的路由功能.
好吧,基本上我有一个项目要求视频对用户隐藏,同时仍能看到它们(通过使用php).这是我到目前为止所得到的:
video.php文件包含:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'path/to/movie.mp4');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$out = curl_exec($ch);
curl_close($ch);
header('Content-type: video/mp4');
header('Content-type: video/mpeg');
header('Content-disposition: inline');
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($out));
echo $out;
exit();
?>
Run Code Online (Sandbox Code Playgroud)
并且应该显示的html文件正在使用html5.现在这里的事情......当我直接嵌入这个(不是)时它起作用.但它不适用于我的iPhone并且无法在标签中工作...如果我使用直接文件而不是php包装器,一切正常,在我的iPhone上也是如此...
所以我想我的问题是这样的:什么是正确的header()信息来完美复制可以通过iPhone和HMTL5流式传输的mp4?
解决方案源自:http://mobiforge.com/developing/story/content-delivery-mobile-devices
video.php文件:
<?php
$file = 'path/to/videofile.mp4';
$fp = @fopen($file, 'rb');
$size = filesize($file); // File size
$length = $size; // Content length
$start = 0; // Start byte
$end = $size - 1; // End byte
header('Content-type: video/mp4');
header("Accept-Ranges: 0-$length");
if (isset($_SERVER['HTTP_RANGE'])) …Run Code Online (Sandbox Code Playgroud) 我想将我的Asics运行计划导出到iCal,由于Asics不提供这项服务,我决定为自己个人使用构建一个小刮刀.我想要做的是从我的计划中获取所有计划的运行并基于此生成iCal源.我正在使用C#和Html Agility Pack.
我想要做的是遍历我所有的预定运行(它们是div节点).然后我想用我的运行节点选择几个不同的节点.我的代码看起来像这样:
foreach (var run in doc.DocumentNode.SelectSingleNode("//div[@id='scheduleTable']").SelectNodes("//div[@class='pTdBox']"))
{
number++;
string date = run.SelectSingleNode("//div[@class='date']").InnerText;
string type = run.SelectSingleNode("//span[@class='menu']").InnerHtml;
string distance = run.SelectSingleNode("//span[@class='distance']").InnerHtml;
string description = run.SelectSingleNode("//div[@class='description']").InnerHtml;
ViewData["result"] += "Dato: " + date + "<br />";
ViewData["result"] += "Tyep: " + type + "<br />";
ViewData["result"] += "Distance: " + distance + "<br />";
ViewData["result"] += "Description: " + description + "<br />";
ViewData["result"] += run.InnerHtml.Replace("<", "<").Replace(">", ">") + "<br />" + "<br />" + "<br />";
}
Run Code Online (Sandbox Code Playgroud)
我的问题是run.SelectSingleNode("//div[@class='date']").InnerText …
我在MVC网站上使用Entity Framework
我试图获取使用原始查询的记录数.
我正在寻找这些方面的东西,但任何人都会满意任何解决方案.
var sql = SELECT COUNT(*) FROM dbo.Articles WHERE (CategoryID = 3)
var total = _context.Database.SOMETHING(sql)
Run Code Online (Sandbox Code Playgroud)
我意识到,对于这样一个简单的场景,原始查询可能是不走,但在现实的方式,SQL字符串是更加复杂,以至于它几乎是不可能的使用LINQ到SQL.
我想在div点击上改变我的吐司的位置类.
positionclass:未更改为Bottom.?我在这里失踪了什么?
以及如何使用
toastr.optionsOverride ='positionclass:toast-bottom-full-width';
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<head>
<title></title>
<script type ="text/javascript" src ="@Url.Content("~/Scripts/jquery-1.6.4.js")"></script>
<script type ="text/javascript" src ="@Url.Content("~/Scripts/toastr.js")"></script>
<link rel="stylesheet" type="text/css" href="~/content/toastr.css" />
</head>
<script type="text/javascript">
$(document).ready(function () {
// show when page load
toastr.info('Page Loaded!');
$('#linkButton').click(function () {
toastr.optionsOverride = 'positionclass:toast-bottom-full-width';
// show when the button is clicked
toastr.success('Click Button', 'ButtonClick', 'positionclass:toast-bottom-full-width');
});
});
</script>
<body>
<div id ="linkButton" > click here</div>
</body>
Run Code Online (Sandbox Code Playgroud)
更新1
调试之后我注意到toastr.js下面的getOptions方法覆盖'positionclass:toast-bottom-full-width'到'toast-top-right'
function getOptions() {
return $.extend({}, defaults, toastr.options);
}
Run Code Online (Sandbox Code Playgroud)
更新2 …
出于某种原因,我的Visual Studio 2013 Preview无法创建MVC 5项目.由于MVC项目现在是CodePlex的开源项目,我想知道是否有一种简单的方法可以在我的Visual Studio 2012 Ultimate中开发MVC 5项目.
我刚刚在VS 2013 RTM上创建了一个新的MVC 5应用程序.出于某种原因,我的CSS文件中的背景图片网址没有被转换.
因此,为了调试该问题,我创建了自定义CssRewriteUrlTransform包装器.我发现我的断点没有被调用.
这就是我在BundleConfig.cs中的内容
using System.Web.Optimization;
namespace Utilities.Web
{
public class BundleConfig
{
private const string JQUERY_CDN_URL = "//code.jquery.com/jquery-1.10.1.min.js";
public static void RegisterBundles(BundleCollection bundles)
{
bundles.UseCdn = true;
BundleTable.EnableOptimizations = true;
bundles.Add(new StyleBundle("~/css/coming-soon")
.Include("~/Content/Site/coming-soon.css",
new CssRewriteUrlTransformWrapper()));
bundles.Add(new ScriptBundle("~/js/coming-soon")
.Include("~/Scripts/jquery.placeholder.js")
.Include("~/Scripts/Site/coming-soon.js"));
bundles.Add(new ScriptBundle("~/js/jquery", JQUERY_CDN_URL)
{
CdnFallbackExpression = "window.jQuery"
}.Include("~/Scripts/jquery-{version}.js"));
}
}
public class CssRewriteUrlTransformWrapper : IItemTransform
{
public string Process(string includedVirtualPath, string input)
{
return new CssRewriteUrlTransform().Process(includedVirtualPath, input);
}
}
}
Run Code Online (Sandbox Code Playgroud) asp.net-mvc ×6
c# ×2
php ×2
codeigniter ×1
html5 ×1
iphone ×1
jquery ×1
mp4 ×1
multi-select ×1
scope ×1
selectlist ×1
sql-server ×1
symfony ×1
symfony-2.3 ×1
templates ×1
toastr ×1
yaml ×1