我完成了NerdDinner教程,现在我正在玩一些项目.索引页面显示所有即将到来的晚餐:
public ActionResult Index()
{
var dinners = dinnerRepository.FindUpComingDinners().ToList();
return View(dinners);
}
Run Code Online (Sandbox Code Playgroud)
在DinnerRepository类我有方法FindAllDinners,我想添加到所有晚餐的索引方法编号,如下所示:
public ActionResult Index()
{
var dinners = dinnerRepository.FindUpComingDinners().ToList();
var numberOfAllDinners = dinnerRepository.FindAllDinners().Count();
return View(dinners, numberOfAllDinners);
}
Run Code Online (Sandbox Code Playgroud)
当然,这不起作用.因为我对OOP很陌生,所以我需要帮助.
谢谢,
Ile
我正在尝试使用fadeIn效果将图像加载到div中.问题是我不知道如何避免同时加载和褪色.我想要加载图像,在完全加载后它应该被淡入.
http://www.izrada-weba.com/vedranmarketic
这些是图像拇指:
<div id="thumbs">
<a href="#" class="slika_thumb" id="1"><img src="slike/th.jpg" border="0"/></a><a href="#" class="slika_thumb" id="2"><img src="slike/th.jpg" border="0"/></a><a href="#" class="slika_thumb" id="3"><img src="slike/th.jpg" border="0"/></a><a href="#"><img src="slike/th.jpg" border="0"/></a><a href="#"><img src="slike/th.jpg" border="0"/></a><a href="#"><img src="slike/th.jpg" border="0"/></a> </div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是应该加载图像的容器:
<div id="desna_kolona">
<div id="slika"><img src="slike/c6.jpg" /></div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是jquery文件:
$(document).ready(function(){
$('.slika_thumb').click(function() {
var id = $(this).attr("id");
$('#slika').hide();
$.ajax({
url: 'slike/slika.php?id=' + id,
success: function(data) {
$('#slika').html(data);
$('#slika').fadeIn();
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
我尝试使用complete下面success但仍然相同的结果.有什么建议?
我需要获取元素相对于其父元素的位置.position()假设这样做,但它看起来没有.
<!DOCTYPE html>
<html>
<head>
<style>
body{padding: 0px; margin: 0px;}
div { margin-left: 200px; padding: 30px; border: 1px solid red;}
p { margin: 0px; padding: 0px; border: 1px solid black }
</style>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
<script>
$(document).ready(function() {
var p = $("p.paragraf");
var position = p.offset();
$("p.zadnji").text( "left: " + position.left + ", top: " + position.top );
});
</script>
</head>
<body>
<div class="container">
<p class="paragraf">Hello</p>
</div>
<p class="zadnji"></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
结果:
左:231,上:31
如果p.paragraf是在里面#container那么#container …
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ViewFlipper
android:layout_margin="6dip"
android:id="@+id/view_flipper"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/photo1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/photo2"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/photo3"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/photo4"/>
</ViewFlipper>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
主要活动:
public class MainActivity extends Activity {
private ViewFlipper vf;
private float lastX;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vf = (ViewFlipper) findViewById(R.id.view_flipper);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public boolean onTouchEvent(MotionEvent touchevent) {
switch (touchevent.getAction())
{
case MotionEvent.ACTION_DOWN:
{ …Run Code Online (Sandbox Code Playgroud) https://github.com/angular-ui/ui-select
此搜索插件使用找到匹配项'LIKE %word%'.可以将其更改为'LIKE word%'
示例:如果我在搜索状态时键入字母'T',则当前返回以下内容:
H I
I D
I L
I N
I A
M I
R I
...
我想它返回:
我 ð
我大号
我 ñ
我一个
int newWidth = 100;
int newHeight = 100;
double ratio = 0;
if (img1.Width > img1.Height)
{
ratio = img1.Width / img1.Height;
newHeight = (int)(newHeight / ratio);
}
else
{
ratio = img1.Height / img1.Width;
newWidth = (int)(newWidth / ratio);
}
Image bmp1 = img1.GetThumbnailImage(newWidth, newHeight, null, IntPtr.Zero);
bmp1.Save(Server.MapPath("~/Uploads/Photos/Thumbnails/") + photo.PhotoID + ".jpg");
Run Code Online (Sandbox Code Playgroud)
我总是得到具有相同值的高度和宽度的图像(100)
我在做类型转换时出错了吗?
有关ASP.NET MV2的一些事情我不清楚.在数据库中,我有Contacts几个字段的表,还有一个XmlFields类型为的附加字段xml.在该字段中存储了附加描述字段.
共有4个班级:
Contact对应于Contact表的类,在创建LINQ类时默认定义ContactListView继承
Contact类并具有一些附加属性的类ContactXmlView包含字段中XmlFields字段的类ContactDetailsView类合并ContactListView并
ContactXmlView成一类,这一个用于显示在视图页面数据ContactListViewclass已经从Contact类中重新定义了一些属性(这样我就可以添加[Required]用于验证的过滤器) - 但是我得到了警告消息:
'ObjectTest.Models.Contacts.ContactListView.FirstName'隐藏继承的成员'SA.Model.Contact.FirstName'.如果要隐藏,请使用new关键字.
ContactDetailsView 在创建新联系人并将其添加到数据库时,也会在表单中使用class.
我不确定这是否正确,警告信息让我感到困惑.对此有何建议?
谢谢,
Ile
编辑
根据雅各布的指示,我从头开始尝试:
[MetadataType(typeof(Person_Validation))]
public partial class Person
{
}
public class Person_Validation
{
[Required]
string FirstName { get; set; }
[Required]
string LastName { get; set; }
[Required]
int Age { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在控制器我有这个:
[HttpPost] …Run Code Online (Sandbox Code Playgroud) 使用jQuery,是否可以调用/ControllerName/GetSomething?parameter=test,而在GetSomething方法中我有以下内容:
public ActionResult Details()
{
filterQuery.OrderBy = Request.QueryString["parameter"];
var contacts = contactRepository.FindAllContacts(filterQuery).ToList();
return View("ContactList");
}
Run Code Online (Sandbox Code Playgroud)
然后fadeOut当前显示的ContactList.ascx用更新的替换它?
<td class="profile">
<% var usedColors = ViewData["usedColors"] as string[]; %>
<a class="profile-color" href="#" style="background: #c00; <% if (usedColors.Contains("#c00") && Model.Color != "#c00") {%>display:none<% }%>" id="color-c00">Color1</a>
<a class="profile-color" href="#" style="background: #3491c2; <% if (usedColors.Contains("#3491c2") && Model.Color != "#3491c2") {%>display:none<% }%>" id="color-3491c2">Color2</a>
<a class="profile-color" href="#" style="background: #ca5c00; <% if (usedColors.Contains("#ca5c00") && Model.Color != "#ca5c00") {%>display:none<% }%>" id="color-ca5c00">Color3</a>
<a class="profile-color" href="#" style="background: #6c0; <% if (usedColors.Contains("#6c0") && Model.Color != "#6c0") {%>display:none<% }%>" id="color-6c0">Color4</a>
<a class="profile-color" href="#" style="background: #5a35a4; <% if (usedColors.Contains("#5a35a4") && Model.Color …Run Code Online (Sandbox Code Playgroud) 我有一个C++项目需要编辑.这是变量的声明:
// Attachment
OFSTRUCT ofstruct;
HFILE hFile = OpenFile( mmsHandle->hTemporalFileName , &ofstruct , OF_READ );
DWORD hFileSize = GetFileSize( (HANDLE) hFile , NULL );
LPSTR hFileBuffer = (LPSTR)GlobalAlloc(GPTR, sizeof(CHAR) * hFileSize );
DWORD hFileSizeReaded = 0;
ReadFile( (HANDLE) hFile , hFileBuffer, hFileSize, &hFileSizeReaded, NULL );
CloseHandle( (HANDLE) hFile );
Run Code Online (Sandbox Code Playgroud)
我需要检查文件是否附加(我想我需要检查hFile是否有任何值),但不知道如何.我尝试过,hFile == NULL但这不起作用.
谢谢,
Ile
我正在开发asp.net mvc2应用程序,我使用asp.net成员资格提供程序,它使用ASPNETDB.mdf数据库.我也有自己的数据库,现在我想知道如何将这2个数据库上传到服务器?我应该将它们上传为.mdf文件还是应该使用SQL服务器?我更喜欢使用SQL服务器,如果有人知道转换和上传这两个数据库的最短路径,那将对我有很大帮助.
在此先感谢,
Ilija
表具有可为空的ContactDate字段.我想对这些记录进行排序,以便非空值首先按升序排列,然后在非可空值之后对空值进行排序.
Select * from myTable Order by ContactDate ASC
Run Code Online (Sandbox Code Playgroud)
返回以下
NULL
NULL
NULL
NULL
2015-07-27 10:00:00.000
2015-07-29 10:00:00.000
Run Code Online (Sandbox Code Playgroud)
然后,
Select * from myTable Order by ContactDate DESC
Run Code Online (Sandbox Code Playgroud)
返回以下
2015-07-29 10:00:00.000
2015-07-27 10:00:00.000
NULL
NULL
NULL
NULL
Run Code Online (Sandbox Code Playgroud)
但我需要这样:
2015-07-27 10:00:00.000 -- asc
2015-07-29 10:00:00.000 -- asc
NULL
NULL
NULL
NULL
Run Code Online (Sandbox Code Playgroud)
使用MS SQL Server 2012
我正在使用jquery和uploadify将照片上传到服务器.上传照片后,使用ajax将它们添加到div容器中.一切都很好,除了DELETE按钮.所有删除按钮都适用于页面加载,但通过ajax添加的按钮不起作用.我想这是因为我定义了能够删除图像的功能,并且没有使用"经典"删除方式(表单删除):
// Delete photo
$(".blog_slike .delete_slika").click(function() {
var commentContainer = $(this).parent().parent();
var id = $(this).attr("id");
var string = 'id='+ id ;
$.ajax({
type: "POST",
url: "./include/ajax-edit/delete.php?polje=blog_slika",
data: string,
cache: false,
success: function(){
commentContainer.fadeOut("slow");
$('#load').fadeOut();
}
});
return false;
});
Run Code Online (Sandbox Code Playgroud)
知道如何使用append()函数将按钮添加到html代码后使按钮工作吗?
还有一件事......将照片添加到tinymce编辑器中我使用此功能:
<a href=\"javascript:;\" onmousedown=\"tinyMCE.execCommand('mceInsertContent',false,'$slike_u_sadrzaj');\">Ubaci sve slike u blog</a>
Run Code Online (Sandbox Code Playgroud)
...也是在页面加载时添加的.如何将内容添加到所在$slike_u_sadrzaj位置以及如何删除它?
谢谢,Ile
jquery ×5
ajax ×2
c# ×2
android ×1
angularjs ×1
append ×1
asp.net ×1
asp.net-mvc ×1
aspnetdb ×1
c++ ×1
database ×1
double ×1
eclipse ×1
fadein ×1
file ×1
image ×1
integer ×1
java ×1
javascript ×1
load ×1
nerddinner ×1
object ×1
offset ×1
parent ×1
position ×1
search ×1
select ×1
sorting ×1
sql ×1
sql-server ×1
viewflipper ×1
winapi ×1