我想在成功操作后呈现相同的视图(而不是使用RedirectToAction),但我需要修改呈现给该视图的模型数据.以下是一个人为的示例,演示了两种不起作用的方法:
[AcceptVerbs("POST")]
public ActionResult EditProduct(int id, [Bind(Include="UnitPrice, ProductName")]Product product) {
NORTHWNDEntities entities = new NORTHWNDEntities();
if (ModelState.IsValid) {
var dbProduct = entities.ProductSet.First(p => p.ProductID == id);
dbProduct.ProductName = product.ProductName;
dbProduct.UnitPrice = product.UnitPrice;
entities.SaveChanges();
}
/* Neither of these work */
product.ProductName = "This has no effect";
ViewData["ProductName"] = "This has no effect either";
return View(product);
}
Run Code Online (Sandbox Code Playgroud)
有谁知道实现这个的正确方法是什么?
类文件C:\ WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files \中的冲突阻止我构建解决方案.即使我尝试清空文件夹,每次Visual Studio启动构建过程时,它都会将类文件导入到具有相同文件夹名称的临时文件夹中.如果我重新启动机器或将其保留一夜,项目构建没有错误.有没有告诉Visual Studio删除/忽略/清除可能在临时文件夹中的任何延迟类文件?
VS中的清洁解决方案选项也不起作用.冲突中的类文件来自App_Code文件夹.
问题:2个项目共享主干并正在更新一些相同的文件.现在需要发布一个项目,因此在项目开始之前从检查点创建了一个新分支.
我列出了主线上的变更清单编号.使用它我可以使用带有一系列'p4 describe#'命令的脚本生成列表更改文件和diff输出.
我可以重新格式化该输出并以某种方式将其应用于新分支吗?
可能重复:
类型的默认值
在C#中,要获取Type的默认值,我可以写...
var DefaultValue = default(bool);`
Run Code Online (Sandbox Code Playgroud)
但是,如何为提供的Type变量获取相同的默认值?
public object GetDefaultValue(Type ObjectType)
{
return Type.GetDefaultValue(); // This is what I need
}
Run Code Online (Sandbox Code Playgroud)
或者,换句话说,"默认"关键字的实现是什么?
我正在开始一个新项目.我熟悉TortoiseSVN及其所有缺点.我应该开始使用Mercurial吗?使用Mercurial而不是Subversion有什么优缺点?
我需要使用lxml下载并解析网页并构建UTF-8 xml输出.我认为伪代码模式更具说明性:
from lxml import etree
webfile = urllib2.urlopen(url)
root = etree.parse(webfile.read(), parser=etree.HTMLParser(recover=True))
txt = my_process_text(etree.tostring(root.xpath('/html/body'), encoding=utf8))
output = etree.Element("out")
output.text = txt
outputfile.write(etree.tostring(output, encoding=utf8))
Run Code Online (Sandbox Code Playgroud)
所以webfile可以是任何编码(lxml应该处理这个).Outputfile必须是utf-8.我不知道在哪里使用编码/编码.这个架构好吗?(我找不到关于lxml和编码的好教程,但我可以发现很多问题...)我需要强大的解决方案.
编辑:
因此,对于发送utf-8到lxml,我使用
converted = UnicodeDammit(webfile, isHTML=True)
if not converted.unicode:
print "ERR. UnicodeDammit failed to detect encoding, tried [%s]", \
', '.join(converted.triedEncodings)
continue
webfile = converted.unicode.encode('utf-8')
Run Code Online (Sandbox Code Playgroud) 可能我还不了解TableLayout的布局属性.似乎不可能像HTML那样实现这样灵活的表,因为没有单元格.我的目标是实现这样的布局:

我怎样才能做到这一点?我想过使用GridView,但这似乎在XML中没用.我的努力看起来像这样:
<TableLayout
android:id="@+id/tableLayout"
android:layout_width="320sp"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:gravity="bottom"
android:layout_alignParentBottom="true">
<TableRow
android:background="#333333"
android:gravity="bottom"
android:layout_width="fill_parent">
<Button
android:id="@+id/btnUp"
android:layout_width="60sp"
android:layout_height="50sp"
android:gravity="left"
android:text="Lift U"
/>
<Button
android:id="@+id/btnScreenUp"
android:gravity="right"
android:layout_gravity="right"
android:layout_width="60sp"
android:layout_height="50sp"
android:text="Scrn U"
/>
</TableRow>
<TableRow
android:background="#444444"
android:gravity="bottom"
android:layout_gravity="right">
<Button
android:id="@+id/btnDown"
android:layout_width="60sp"
android:layout_height="50sp"
android:text="Lift D"
/>
<Button
android:id="@+id/btnScreenLeft"
android:layout_width="60sp"
android:layout_height="50sp"
android:gravity="right"
android:layout_gravity="right"
android:text="Scrn L"
/>
<Button
android:id="@+id/btnScreenDown"
android:layout_width="60sp"
android:layout_height="50sp"
android:gravity="right"
android:layout_gravity="right"
android:text="Scrn D"
/>
<Button
android:id="@+id/btnScreenRight"
android:layout_width="60sp"
android:layout_height="50sp"
android:gravity="right"
android:layout_gravity="right"
android:text="Scrn R"
/>
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud) 我正在使用ImageMagick将一些文件从一种格式转换为另一种格式.我总是认为.png文件应该像.jpg一样大/小,如果不小,并且肯定小于.gif.
但是,当我跑
convert photo.jpg photo.png
Run Code Online (Sandbox Code Playgroud)
我拿出的文件比原来的jpg大6倍.
原始jpg是一张约300x500像素,52 kb的常规照片.输出是相同尺寸的合适png,但大小约为307 kb?
是否有人知道hack正在发生什么?难道我做错了什么?
PS:
我在Debian和Windows上都尝试了相同的结果.
PPS:
此外,当我为此添加调整大小选项并调整为10000 x 10000.转换和调整大小到jpg需要几秒钟,但它的工作原理,如果我做同样的png,我jsut strt完全耗尽了内存
PPPS: 对于那些将此问题标记为PNG与GIF与JPEG与SVG重复的人- 何时最好使用?.请仔细阅读并理解问题.这不是重复,因为这个问题询问'关于以特定应用程序(图像magick)编程生成的文件.您标记为重复的问题是询问哪种图像格式更适合在网络上使用.两个不同的问题.
Google App Engine说"必须首先进行身份验证".在尝试部署任何应用时:
me@myhost /opt/google_appengine $ python appcfg.py update ~/sda2/workspace/lyapapam/
Application: lyapapam; version: 1.
Server: appengine.google.com.
Scanning files on local disk.
Scanned 500 files.
Scanned 1000 files.
Initiating update.
Email: <email_here>@gmail.com
Password for <email_here>@gmail.com:
Error 401: --- begin server output ---
Must authenticate first.
--- end server output ---
Run Code Online (Sandbox Code Playgroud)
我们收到此消息的任何应用程序和我们可用的任何开发人员帐户
这就是我们安装的:
Python - 2.5.5 App Engine SDK - 1.3.2
PIL - 1.1.7 ssl - 1.15
Run Code Online (Sandbox Code Playgroud)
我该如何解决?这是众所周知的问题吗?
更新:
在安装了Gentoo的同一台计算机上安装Windows后,我确实遇到了时间同步的问题,但我很快就通过在注册表中设置RealTimeIsUniversal并在两个系统中设置与europe.pool.ntp.org的同步来解决这个问题.(顺便说一句,我的时区是EEST)
在我解决了时间同步问题后的几天,appcfg.py在打印出来的每一行之后都要求我输入密码(这真的很奇怪)并且我使用了--passin和unix'yes'.
现在我遇到了"必须先验证"的问题.我花了很多时间在Windows和Linux上使用不同组合的--passin --insecure --no_cookies选项,但没有任何成功.
我以为我弄明白了,但事实证明我只是删除了第一张唱片.以下内容返回重复的行.所有都有2.我只想删除每个重复记录的第一个.
select scorestudentid, scoreadvisor, scorecorrect, count(*)
from scores
where scoretestid = 3284
group by scorestudentid, scoreadvisor, scorecorrect
having count(scorestudentid) > 1
Run Code Online (Sandbox Code Playgroud)
哪个回报:
scorestudentid scoreadvisor scorecorrect no column name
13033719 28059 3.0 2
13033777 28086 3.0 2
13033826 28147 3.0 2
13033960 28023 3.0 2
Run Code Online (Sandbox Code Playgroud)
所以我把它放在一起认为它会起作用:
set rowcount 1
delete
from scores
where scoretestid = 3284
and scorestudentid in (
select scorestudentid
from scores
where scoretestid = 3284
group by scorestudentid
having count(scorestudentid) > 1)
Run Code Online (Sandbox Code Playgroud)
它看起来应该是一个简单的概念,但我没有得到它.
基于托马斯脚本我更新了查询以适应但它仍然无法正常工作.
Delete Scores
Where Exists …Run Code Online (Sandbox Code Playgroud) .net ×2
c# ×2
python ×2
android ×1
app-code ×1
asp.net ×1
asp.net-mvc ×1
gif ×1
imagemagick ×1
jpeg ×1
lxml ×1
mercurial ×1
perforce ×1
png ×1
runtime ×1
sql ×1
svn ×1
tortoisehg ×1
tortoisesvn ×1
types ×1