我有动态创建TextBox的问题.
在PageLoad中创建TextBox时,会触发TextChanged事件.
但是当我动态删除并重新创建TextBox时,TextChanged没有被触发.
这是代码:
.aspx文件
<body>
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell ColumnSpan="2">Fixed content</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
Run Code Online (Sandbox Code Playgroud)
.cs文件
public partial class test : System.Web.UI.Page
{
string myText = "a";
protected void Page_Load(object sender, EventArgs e)
{
WriteRows();
}
private void WriteRows()
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
TextBox txt = new TextBox();
txt.Text = myText;
txt.TextChanged += new EventHandler(txt_TextChanged); // Assign event handler
tc.Controls.Add(txt);
tr.Controls.Add(tc);
tc = new TableCell();
tc.Text = …
Run Code Online (Sandbox Code Playgroud) 如何将MultiSelectList与复选框列表相关联?
例如.我把这样的东西传给了模特
model.Groups = new MultiSelectList(k.Groups, "Id", "Name", selectedGroups)
Run Code Online (Sandbox Code Playgroud)
我应该如何呈现它?这不起作用
<% foreach (var item in Model.Groups.Items) { %>
<input type="checkbox" name="groups" value="<%=item.Value%>" id="group<%=item.Value%>" checked="<%=item.Selected?"yes":"no"%>" />
<label for="group<%=item.Value%>"><%=item.Text%></label>
<% } %>
Run Code Online (Sandbox Code Playgroud)
错误CS1061:'object'不包含'Value'的定义...
我可以使用HTML Helper方法吗?
(然后,除非它很简单,否则在提交表单时我应该如何在Controller上获取所选值?)
我的数据库中有一个非常大的表,我开始收到此错误
无法为数据库'mydatabase'分配新页面,因为文件组'PRIMARY'中的磁盘空间不足.通过删除文件组中的对象,向文件组添加其他文件或为文件组中的现有文件设置自动增长来创建必要的空间.
你如何解决这个错误?我不明白那里的建议.
出于好奇......
有没有办法在ASPX/ASCX文件中添加"使用"?
例如.就像是
<% using umbraco.NodeFactory; %>
Run Code Online (Sandbox Code Playgroud)
所以你可以做到
<%= Node.GetCurrent().Name %>
Run Code Online (Sandbox Code Playgroud)
代替
<%= umbraco.NodeFactory.Node.GetCurrent().Name %>
Run Code Online (Sandbox Code Playgroud) 我的Global.asax中有以下内容(Umbraco 4.7)
现在我已升级到Umbraco 6.0.3,global.asax继承自 Umbraco.Web.UmbracoApplication
我在哪里放置我的事件处理程序(以及等效的方法名称)?
我的解开不起作用.
$("img.hoverable").hover(ChangeImage, ChangeBack);
$("a img.hoverable").unbind('hover');
Run Code Online (Sandbox Code Playgroud)
HTML可能是这样的
<img class="hoverable" src="something.jpg"/>
<a href="#"><img class="hoverable" src="something.jpg"/></a>
Run Code Online (Sandbox Code Playgroud)
当我将鼠标悬停在第二个HTML上时,仍会触发ChangeImage.
我不确定我是否正确使用它,有人可以建议吗?
这是我在登录成功时调用的函数.(我对这个FormAuthentication的事情很新)
public static void CreateLoginCookie(User u)
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(u.Id.ToString(), true, 9*60);
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) { Expires = DateTime.Now.AddHours(9) };
HttpContext.Current.Response.Cookies.Add(cookie);
}
Run Code Online (Sandbox Code Playgroud)
在web.config我有
<authentication mode="Forms">
<forms loginUrl="~/Default/Login" timeout="540" />
</authentication>
Run Code Online (Sandbox Code Playgroud)
我希望用户保持登录状态9小时,但它不起作用.他们会在一两个小时后退出.
有人能告诉我我错过了什么吗?
我SortedAscendingHeaderStyle
和我SortedDescendingHeaderStyle
一直没有工作
<asp:GridView ID="grdProducts" runat="server" CssClass="grid" AllowPaging="True" AllowSorting="True" PageSize="100" EmptyDataText="No data to show"
onrowdatabound="grdProducts_RowDataBound" onrowediting="grdProducts_RowEditing" onsorting="grdProducts_Sorting" AutoGenerateEditButton="True">
<AlternatingRowStyle CssClass="even" />
<SortedAscendingHeaderStyle ForeColor="White" CssClass="sorted" />
<SortedDescendingHeaderStyle CssClass="sorted desc" />
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)
单击标题时行正确排序,但是当我使用FireBug检查标题时,它只显示:(这是按升序排序时)
<th scope="col">
<a href="javascript:__doPostBack('ctl00$body$ctl00$grdProducts','Sort$Namekey')">Namekey</a>
</th>
Run Code Online (Sandbox Code Playgroud)
ForeColor和CssClass根本没有设置.
任何人都知道我做错了什么?
编辑:我的C#代码落后
protected void grdProducts_Sorting(object sender, GridViewSortEventArgs e)
{
if ((string)ViewState["SortColumn"] == e.SortExpression)
ViewState["SortDirection"] = ((string)ViewState["SortDirection"] == "") ? " DESC" : "";
else
{
ViewState["SortColumn"] = e.SortExpression;
ViewState["SortDirection"] = "";
}
}
protected override void OnPreRender(EventArgs e)
{
BindGrid();
base.OnPreRender(e); …
Run Code Online (Sandbox Code Playgroud) 我打电话打开弹出窗口
$.colorbox({ href: "notification.aspx" });
Run Code Online (Sandbox Code Playgroud)
在notification.aspx我有
<script type="text/javascript" src="/scripts/colorbox/jquery.colorbox-min.js"></script>
...
<a id="btnClose">OK</a>
Run Code Online (Sandbox Code Playgroud)
弹出窗口显示正常,但是当我单击按钮时,它会出现JavaScript错误.
在主页面的javascript我有
$('#btnClose').live('click', function () {
alert('closing...'); // Alert shown as expected
$.colorbox.close(); // Nothing happens, no JavaScript error
//$.fn.colorbox.close(); // same
//parent.$.fn.colorbox.close(); // same
//$.colorbox.remove(); // same
//$('#cboxClose').click(); // same
//$('#cboxOverlay').click(); // same
});
Run Code Online (Sandbox Code Playgroud)
我只想关闭弹出窗口.
我错过了什么?提前致谢.
编辑:我得到它以某种方式工作,我会找出使它有效的原因.
在示例代码中,这是从.cshtml文件获取主页的方式
var homePage = CurrentPage.AncestorsOrSelf(1).First();
Run Code Online (Sandbox Code Playgroud)
现在,如何通过ID获取特定页面/节点(与当前页面无关,例如新闻页面)?
asp.net ×4
c# ×3
.net ×2
jquery ×2
umbraco ×2
asp.net-mvc ×1
colorbox ×1
events ×1
global-asax ×1
gridview ×1
html-helper ×1
razor ×1
sql ×1
sql-server ×1
umbraco7 ×1
unbind ×1