这个web控件怎么写

OICQshenshi 2009-09-16 10:11:35
Assume a web control in Asp.Net is defined as following:
public class SampleWebControl : WebControl, IPostBackEventHandler
{
public SampleWebControl(){
}
}

However, the above class hasn't been finished yet. One additional method has to be added to the class, otherwise, C# compiler won't pass. Please give the name of the method, and briefly describe what can be achieved by using the method.
...全文
83 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xie_yanke 2009-09-17
  • 打赏
  • 举报
回复
COPY MSDN:
using System;
using System.Web.UI;
using System.Collections;
using System.Collections.Specialized;

namespace CustomControls {

[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
public class MyButton: Control, IPostBackEventHandler {

// Defines the Click event.
public event EventHandler Click;

//Invoke delegates registered with the Click event.
protected virtual void OnClick(EventArgs e) {

if (Click != null) {
Click(this, e);
}
}


// Define the method of IPostBackEventHandler that raises change events.
public void RaisePostBackEvent(string eventArgument){

OnClick(new EventArgs());
}


protected override void Render(HtmlTextWriter output) {
output.Write("<INPUT TYPE = submit name = " + this.UniqueID +
" Value = 'Click Me' />");
}
}
}

xieliliang 2009-09-17
  • 打赏
  • 举报
回复
帮顶吧
lovnov 2009-09-17
  • 打赏
  • 举报
回复
Seems you are trying to create a custom control which inherits from WebControl.
I think the method should be
protected override void Render(HtmlTextWriter writer)
{

}
OICQshenshi 2009-09-17
  • 打赏
  • 举报
回复
睡前顶下,有人会吗?
OICQshenshi 2009-09-16
  • 打赏
  • 举报
回复
shankaipingo 2009-09-16
  • 打赏
  • 举报
回复
要实现继承的接口吧
OICQshenshi 2009-09-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 yankunlin 的回复:]
要做什么功能的
[/Quote]
随意,最简单的就行,先谢了
yankunlin 2009-09-16
  • 打赏
  • 举报
回复
要做什么功能的
szldk 2009-09-16
  • 打赏
  • 举报
回复
路过,
帮顶,

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧