How to change default form name "aspnetForm" in Beta 2
来源:互联网 发布:软件上线报告 编辑:程序博客网 时间:2024/05/21 10:18
/* from: http://www.cnblogs.com/payne/archive/2007/04/30/733328.html */
Here's the responsible code for that error:
public override string UniqueID{ get { if (this.NamingContainer == this.Page) { return base.UniqueID; } return "aspnetForm"; }}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestBaseForm.aspx.cs" Inherits="TestBaseForm" %>
<%@ Register TagPrefix="LA" Namespace="MyNamespace" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<LA:BaseForm runat="server" id="frmMain">
<div>
</div>
</LA:BaseForm>
</body>
</html>
--------------------------------------------------
BaseForm.cs
--------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace MyNamespace
{
/// <summary>
/// Summary description for BaseForm
/// </summary>
public class BaseForm : System.Web.UI.HtmlControls.HtmlForm
{
public BaseForm() : base() { }
public override string UniqueID
{
get
{
if(this.NamingContainer == this.Page)
{ return base.UniqueID; }
return "frmMain";
}
}
}
}
As you can see, when the naming container is different from the current page (something that happens when you use a master page) the UniqueID property return "aspnetForm". this property is rendered into the name attribute that is sent to the client in the form tag. so, if you really need to, you can create your own form by inheriting from htmlform and then override the UniqueID property or the Name property (this may be a better option).
- How to change default form name "aspnetForm" in Beta 2
- How to change the default browser in Visual Studio
- how to change the implicit default settings in django 1.6
- How to change mysql default data directory in Ubuntu
- How to Change default MySQL Data Directory in Linux111
- Windows - How to change default system font in Windows 10
- How to Change Hostname (Computer Name) in Ubuntu 14.04
- how to change Scheme name
- How To Determine Table/View Name in a Form
- How to programmatically change the default view of an InfoPath form
- How to change the default browser to debug with in Visual Studio 2008?
- How to Change Default Audio Device
- How to Change the Default System Fonts
- how to change kvm default storage position.
- Understanding Object Ownership in sql 2000(how to change the schema table name in sql 2000)
- Mac - How to change default system font in Mac OS X Yosemite
- Mac - How to change default system font in Mac OS X El Capitan
- How to Change Domain Name? ejabberd
- poj 2524 并查集
- struts框架
- Ubuntu 下VIM使用指南
- 总结一下subversion
- 23种设计模式的形象比喻
- How to change default form name "aspnetForm" in Beta 2
- java取得spring's ApplicationContext的方法
- Linux queue.h之TAILQ队列分析!
- Windows Server、Oracle用户数概念解疑
- 多线程渲染(Multithreaded- rendering)3D引擎实例分析 : FlagshipEngine
- tail queue in queue.h for free bsd.
- 手机测试
- VC++中CSliderCtrl用法
- linux创建用户的学习