前台:
function winpup()
{
if ( document.getelementbyid('').value == )
{
alert(不能为空!);
return false;
}
else
{
alert(chen);
return true;
}
}
后台:
using system;
using system.data;
using system.configuration;
using system.collections;
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;
using system.data.sqlclient;
using system.componentmodel;
public partial class chenlogin : system.web.ui.usercontrol
{
private string txtname = ;
private string reuri = ;
private string datasource = ;
private string lbltext = 请填写。;
public string txtname
{
get
{
return this.textbox1.text.trim();
}
}
public string reuri
{
set
{
reuri = value;
}
}
public string datasources
{
set
{
datasource = value;
}
}
//[category(demo), description(demo from idothink.com)]
public string lbltext
{
get
{
return lbltext;
}
set
{
lbltext = value;
this.invalidate();
}
}
private void invalidate()
{
this.label1.text = lbltext;
}
protected void page_load(object sender, eventargs e)
{
if (!ispostback)
{
button1.attributes.add(onclick, return winpup(););
button1.attributes.add(style, border:1px solid #f00;color:#f00;);
}
}
//protected override void onpaint(painteventargs pe)
//{
// // calling the base class onpaint
// base.onpaint(pe);
// // custom paint code here
// pe.graphics.drawstring(
// hellovalue,
// font,
// new solidbrush(forecolor),
// clientrectangle, new stringformat());
//}
protected void button1_click(object sender, eventargs e)
{
//response.redirect(reuri);
this.label1.text = this.textbox1.text;
}
}
如何引用用户控件请查看:
http://blog.csdn.net/ajaxchen_615/archive/2009/05/22/4208247.aspx
