如何在c#的mouseicon上显示文本.由于ShowBalloonTip显示超时,如何在鼠标悬停时显示Notify图标上的文本?
请参阅以下代码:
string test = "";
int output = -1;
if (int.TryParse(test, out output))
{
Console.WriteLine("Parsed");
}
Console.WriteLine(output);
Run Code Online (Sandbox Code Playgroud)
当TryParse()
失败时,不应该跳过块,Console.WriteLine("Parsed")
不调用和值output
相同(-1)?
它正在回归 0
我用这种方式填充了组合框
foreach (Control c in this.Controls)
{
if (c is ComboBox)
{
(c as ComboBox).DataSource = DataSet1.Tables[0];
(c as ComboBox).DisplayMember = "Articles";
}
}
Run Code Online (Sandbox Code Playgroud)
但是,问题是当我在一个组合中更改SelectedItem时 - 它在所有其他组合中变得更改了吗?
做这样的事情是否有更好的方法:
private XElement GetSafeElem(XElement elem, string key)
{
XElement safeElem = elem.Element(key);
return safeElem ?? new XElement(key);
}
private string GetAttributeValue(XAttribute attrib)
{
return attrib == null ? "N/A" : attrib.Value;
}
var elem = GetSafeElem(elem, "hdhdhddh");
string foo = GetAttributeValue(e.Attribute("fkfkf"));
//attribute now has a fallback value
Run Code Online (Sandbox Code Playgroud)
从XML文档解析元素/属性值时?在某些情况下,在执行以下操作时可能找不到该元素:
string foo (string)elem.Element("fooelement").Attribute("fooattribute").Value
Run Code Online (Sandbox Code Playgroud)
因此会发生对象引用错误(假设未找到元素/属性).尝试访问元素值时相同
早上好.我正在制作一个简单的jQuery画廊的问题.它允许用户通过一些按钮循环浏览一组图像,同时在计时器上旋转这些图像.我的问题是用户能够多次点击该按钮,将淡入淡出的动画排队并反复重复,例如用户点击按钮5次>相同图像淡入/淡出5次>图库移动到下一张图像.
我尝试过使用:
$('#homeGalleryImage li a').unbind('click');
触发click事件然后重新绑定后:
$('#homeGalleryImage li a').bind('click');
完成之后,这只是在按下一次按钮之后删除了点击事件并且从不重新绑定它?
我也试过通过以下方式禁用按钮:
$('#homeGalleryImage li a').attr('disabled', true);
无济于事......?
还有一个次要问题,如果您在图像处于转换状态时设置单击按钮,则下一个图像显示为"淡化",就像不透明度已降低一样?很奇怪......以下是按钮点击的代码:
var i = 1;
var timerVal = 3000;
$(function () {
$("#homeGalleryControls li a").click(function () {
var image = $(this).data('image');
$('#galleryImage').fadeOut(0, function () {
$('#galleryImage').attr("src", image);
});
$('#galleryImage').fadeIn('slow');
$('.galleryButton').attr("src", "/Content/Images/Design/btn_default.gif");
$(this).find('img').attr("src", "/Content/Images/Design/btn_checked.gif");
i = $(this).data('index') + 1;
if (i == 4) {
i = 0;
}
timerVal = 0;
});
});
Run Code Online (Sandbox Code Playgroud)
以下是在计时器上循环显示图像的代码:
//Cycle through gallery images on a timer
window.setInterval(swapImage, timerVal);
function swapImage() …
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过id
默认路由中的参数从我的数据库中检索数据:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
Run Code Online (Sandbox Code Playgroud)
在这个ActionResult中,我试图基于route id参数呈现自定义用户控件,以便检索所请求页面的相关数据
public ActionResult InitPageNav(int id)
{
PageModel page = PageNavHelper.GetPageByID(id);
return PartialView("UserControls/_PageNavPartial", page);
}
Run Code Online (Sandbox Code Playgroud)
编辑*
public static MvcHtmlString CreateMenuItems(this HtmlHelper helper, string action, string text)
{
var menuItem = new TagBuilder("li");
var link = new TagBuilder("a");
//Get current action from route data
var currentAction = (string)helper.ViewContext.RouteData.Values["action"];
link.Attributes.Add("href", string.Format("/Home/{0}", action));
if …
Run Code Online (Sandbox Code Playgroud) 我有以下正则表达式:
^[a-zA-Z0-9]+( [a-zA-Z0-9]+)*$
Run Code Online (Sandbox Code Playgroud)
我正在尝试验证0到10个字符之间的字符串,该字符串不能包含更多行中的两个空格或不能为空.该字符串不能包含任何特殊字符,并且可以不区分大小写,并且可以包含连字符.
如何将输入限制在0-10个字符之间?
我试过了
^[a-zA-Z0-9]+( [a-zA-Z0-9]+{0,10})*$
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我想知道是否有可能在MVC 3中的一个主要控制器中有几个嵌套控制器?例如:
public class AdminController : Controller
{
public class PagesController : Controller
{
}
//More controllers
}
Run Code Online (Sandbox Code Playgroud)
我试过这个但是无法让它工作,修改了我在global.asx中的路由,但仍然没有.如何AdminController
在网址为例时调用正确的控制器:
/Admin/Pages/Index
Object reference not set to an instance of an object
当我试图找到一个Panel
控件时,我一直收到错误Repeater
.但其他控制措施都很好吗?谁能看到这里有什么问题?
这就是我选择控件的方式:
Panel pnlSubCategories = (Panel)e.Item.FindControl("pnlSubCategories");
Run Code Online (Sandbox Code Playgroud)
标记:
<asp:Repeater ID="rptInnerCategories" runat="server" OnItemDataBound="rptCategories_OnItemDataBound">
<ItemTemplate>
<li id="liCategory" runat="server">
<asp:HyperLink ID="lnkCategory" runat="server">
<span><asp:Literal ID="litCategory" runat="server" Visible="true" /></span>
<asp:Image ID="imgMan" runat="server" Visible="false" /></asp:HyperLink>
<asp:Panel ID="pnlSubCategories" runat="server" Visible="false">
<ul>
<asp:Repeater ID="rptSubCategories" runat="server" Visible="false" OnItemDataBound="rptSubCategories_OnItemDataBound">
<ItemTemplate>
<li id="liSubCategory" runat="server">
<asp:HyperLink ID="lnkSubCategory" runat="server">
<span><asp:Literal ID="litSubCategory" runat="server" /></span></asp:HyperLink>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</asp:Panel>
</li>
</ItemTemplate>
</asp:Repeater>
Run Code Online (Sandbox Code Playgroud)
代码背后:
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) …
Run Code Online (Sandbox Code Playgroud) c# ×9
.net ×3
asp.net-mvc ×2
actionresult ×1
alphanumeric ×1
asp.net ×1
combobox ×1
console ×1
controller ×1
controls ×1
css ×1
gallery ×1
html ×1
javascript ×1
jquery ×1
kinect ×1
linq-to-xml ×1
notifyicon ×1
panel ×1
regex ×1
repeater ×1
routes ×1
tryparse ×1
validation ×1
winforms ×1
xml ×1