好吧我知道它总是取决于具体情况,但到目前为止,我已经将我的jquery文件/插件组合成一个压缩文件.
现在我想知道我应该用我的页面特定的js/jQuery代码做什么.我应该有一个文件,一个Document.Ready函数和我的entires网站js代码吗?或者将它分成每页单独的js文件,每个文件都有文件就绪呼叫?
这些文件将包含诸如.Click特定于某些页面的处理程序和其他jquery代码之类的内容.
什么是最佳实践,以优化加载时间和可维护性?
我有一个Image文件,我想使用System.Drawing类同时裁剪和调整大小
我正在努力建立在本文中的想法:http://www.schnieds.com/2011/07/image-upload-crop-and-resize-with.html
我可以单独裁剪和调整大小但是当我尝试组合这个过程时,我得到了一些奇怪的输出.
这是我一直在尝试的
using (System.Drawing.Bitmap _bitmap = new System.Drawing.Bitmap(w, h))
{
_bitmap.SetResolution(img.HorizontalResolution, img.VerticalResolution);
using (Graphics _graphic = Graphics.FromImage(_bitmap))
{
_graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
_graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
_graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
_graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
//Code used to crop
_graphic.DrawImage(img, 0, 0, w, h);
_graphic.DrawImage(img, new Rectangle(0, 0, w, h), x, y, w, h, GraphicsUnit.Pixel);
//Code I used to resize
_graphic.DrawImage(img, 0, 0, img.Width, img.Height);
_graphic.DrawImage(img, new Rectangle(0, 0, W_FixedSize, H_FixedSize), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel);
//continued...
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中...有两个部分评论...一个裁剪,一个调整大小. …
我一直致力于使用C#开发视频流Web服务的解决方案.我正在使用Windows XP,最新版本的vlc 1.0.3通过LAN网络流式传输视频.但是,目前,我只能设法在自己的电脑上播放视频.现在的问题是我需要在Web服务中执行此流按钮.有没有人知道如何将其更改为Web方法?如何将此Web服务链接到html网页?
以下代码用于使用Windows应用程序流式传输视频.
private void btnStream_Click(object sender, EventArgs e)
{
// Create process and command to run file
System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo(@"C:\videotest.bat");
psi.RedirectStandardOutput = true;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
System.Diagnostics.Process listFiles;
listFiles = System.Diagnostics.Process.Start(psi);
System.IO.StreamReader myOutput = listFiles.StandardOutput;
listFiles.WaitForExit(2000);
if (listFiles.HasExited)
{
string output = myOutput.ReadToEnd();
//this.processResults.Text = output;
}
}
Run Code Online (Sandbox Code Playgroud)
----- C:\ videotest.bat ------
cd "C:\PROGRA~1\VideoLAN\VLC"
vlc c:\alvinchipmunks.vob --sout "#transcode{vcodec=h264,vb=800,scale=1,acodec=mp4a,ab=128,channels=2,samplerate=44100}:duplicate{dst=std{access=udp,mux=ts,dst=152.226.238.64:1234},dst=std{access=udp,mux=ts,dst=152.226.238.59:1234},dst=display}"
Run Code Online (Sandbox Code Playgroud)
任何回复将不胜感激.
谢谢!=)
拥有一个具有另一个视图模型属性的视图模型会被认为是不好的做法吗?...如:
public class PersonViewModel
{
public PersonJobViewModel Peron { get; set;}
//other properties here...
}
Run Code Online (Sandbox Code Playgroud)
编辑
更多关于我的具体情况:
我有一个视图模型,目前包含2个域类.我将此viewmodel传递给一个加载2个局部视图的视图(一个用于viewmodel中的每个域类)
因此,我最终将纯域模型直接传递到局部视图中.
我的想法是,我可以为每个域模型创建一个视图模型,然后将这些2包装到另一个传递给我父模型的视图模型中...
或者有更好的方法来实现这一目标吗?
我有一个带有DateTime参数的对象列表.
我想使用LINQ查询此列表并按日期返回条目,但忽略时间部分
因此,我想选择2012年10月8日任何时间发生的任何条目.
好吧,使用SQL Server 2008.在我的网页上,我有一个文本框,其中连接了jQuery-UI AutoComplete.
现在我需要一个存储过程来搜索单个表的所有列(或者我猜想的多个连接表),以查找来自文本框/自动完成AJAX调用的搜索字符串,并返回"建议的"搜索字符串.我正在使用AdventureWorks数据库进行测试(产品表)
因此,例如,产品表包含产品名称和产品编号(以及其他)的列,我想根据用户输入返回建议的搜索字符串,他们可以在其中输入产品名称和/或产品编号.
我让它在一个简单的专栏中工作.有任何想法吗?
好的我有一个View强制类型作为MyObject的集合
@model IEnumerable<ViewModels.MyObject>
Run Code Online (Sandbox Code Playgroud)
我遍历集合以创建对象列表.
在同一页面上,我需要创建表单来添加新的MyObject.
有没有办法沿着lambda表达式使用Html帮助器来创建从我的模型强类型的元素?
或者最好将此页面的Form部分加载为另一个部分视图,类型为MyObject(不是集合)?
在我的数据库中,我有以下表格:
Person-InterestTag和Post-InterestTag之间存在许多关系
我需要在EF 4.1中执行linq查询以撤回包含至少一个与至少一个与给定用户相关的兴趣标签匹配的兴趣标签的任何帖子.
例
一个人有以下兴趣:
我需要退回任何与汽车,运动或健身相关的帖子.
在性能方面编写此查询的最有效方法是什么?
编辑
根据下面给出的答案遇到错误...
这编译得很好但在运行时抛出错误:
var matchingPosts = posts.Where(post => post.Topics.Any(postTopic => person.Interests.Contains(postTopic)));
Run Code Online (Sandbox Code Playgroud)
错误是:
Unable to create a constant value of type 'System.Collections.Generic.ICollection`1'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
Run Code Online (Sandbox Code Playgroud)
任何想法如何解决这一问题?
编辑2
所以我的课程结构如下:
public class Person
{
public int PersonID {get; set;}
public string FirstName {get; set;}
public string LastName {get; set;}
//other properties of types string, int, DateTime, etc.
public …Run Code Online (Sandbox Code Playgroud) 我正在ASP.NET MVC3中开发和应用程序.我计划利用亚马逊Cloudfront产品作为CDN来提供静态资产.
我很好奇是否有人设计了一种简单的方法来切换用于开发的本地资产和用于部署的基于CDN的资产?
任何提示或技巧将不胜感激.
在尝试配置ServiceStack.net以使用Ninject作为其IOC时,我收到的错误是指未定义的各种绑定.主要用于ICache客户端.
需要创建哪些特定绑定才能正确使用Ninject?
目前已指定:
Bind<ISessionFactory>().To<SessionFactory>();//Is this correct/needed?
Run Code Online (Sandbox Code Playgroud)
注意
我根据ServiceStack文档创建了一个IContainerAdapter来实现Ninject的使用.(在此处找到:ServiceStack IOC Docs)
注意2 我的apphost配置方法如下所示:
public override void Configure(Funq.Container container)
{
IKernel kernel = new StandardKernel(new BindingModule());
container.Adapter = new NinjectContainerAdapter(kernel);
}
Run Code Online (Sandbox Code Playgroud)
注3
我已经注册了ICacheClient,如下所示:Bind().To();
我现在收到指向IRequest的错误
Error activating IRequestLogger\nNo matching bindings are available, and the type is not self-bindable
Run Code Online (Sandbox Code Playgroud)
容器适配器
public class NinjectContainerAdapter : IContainerAdapter
{
private readonly IKernel _kernel;
public NinjectContainerAdapter(IKernel kernel)
{
this._kernel = kernel;
}
public T TryResolve<T>()
{
return this._kernel.Get<T>();
}
public T Resolve<T>()
{
return this._kernel.Get<T>();
} …Run Code Online (Sandbox Code Playgroud) c# ×8
asp.net ×6
asp.net-mvc ×6
.net ×4
javascript ×1
jquery ×1
linq ×1
performance ×1
servicestack ×1
sql ×1
sql-server ×1
t-sql ×1
vlc ×1