弹出对话框点击转向指定页面
Code:
ResponseWrite(<script>windowalert(该会员没有提交申请请重新提交!)</script>);
ResponseWrite(<script>windowlocation =</script>);
弹出对话框
Code:
ResponseWrite(<script language=javascript>alert(产品添加成功!)</script >);
删除文件
Code:
string filename =jpg;
pubutilDeleteFile(HttpContextCurrentServerMapPath(/file/)+filename);
绑定下拉列表框datalist
Code:
SystemDataDataView dv=connExec_ex(select as code请选择经营模式 as content from dealin union select codecontent from dealin);
thisdealincodeDataSource=dv;
thisdealincodeDataTextField=content;
thisdealincodeDataValueField=code;
thisdealincodeDataBind();
thisdealincodeItemsFindByValue(dv[][dealincode]ToString())Selected=true;
时间去秒显示
Code:
<%# SystemDateTimeParse(DataBinderEval(ContainerDataItembegtime)ToString())ToShortDateString()%>
标题带链接
Code:
<%# <a class=\c\ target=\_blank\ href=\_+DataBinderEval(ContainerDataItemprocode)+l\>+ DataBinderEval(ContainerDataItemproname)+</a>%>
修改转向
Code:
<%# <A href=\editpushproaspx?id=+DataBinderEval(ContainerDataItemcode)+\>+修改+</A>%>
弹出确定按钮
Code:
<%# <A id=\btnDelete\ onclick=\return confirm(你是否确定删除这条记录吗?);\ href=\pushproductaspx?dl=+DataBinderEval(ContainerDataItemcode)+\>+删除+</A>%>
输出数据格式化 {:F} 是格式 F表示小数点后剩两位
Code:
<%# DataBinderEval(Container DataItemPriceMoney{:F}) %>
提取动态网页内容
Code:
Uri uri = new Uri();
WebRequest req = WebRequestCreate(uri);
WebResponse resp = reqGetResponse();
Stream str = respGetResponseStream();
StreamReader sr = new StreamReader(strSystemTextEncodingDefault);
string t = srReadToEnd();
thisResponseWrite(tToString());
获取 后面的字符
Code:
iToString()Trim()Substring(iToString()Trim()LastIndexOf()+)ToLower()Trim()
打开新的窗口并传送参数
传送参数
Code:
responsewrite(<script>windowopen(*aspx?id=+thisDropDownListSelectIndex+&id=++)</script>)
接收参数
Code:
string a = RequestQueryString(id);
string b = RequestQueryString(id);
为按钮添加对话框
Code:
ButtonAttributesAdd(onclickreturn confirm(确认?));
buttonattributesadd(onclickif(confirm(are you sure?)){return true;}else{return false;})
删除表格选定记录
Code:
int intEmpID = (int)MyDataGridDataKeys[eItemItemIndex];
string deleteCmd = Delete from Employee where emp_id = + intEmpIDToString()
删除表格记录警告
Code:
private void DataGrid_ItemCreated(Object senderDataGridItemEventArgs e)
{
switch(eItemItemType)
{
case ListItemTypeItem :
case ListItemTypeAlternatingItem :
case ListItemTypeEditItem:
TableCell myTableCell;
myTableCell = eItemCells[];
LinkButton myDeleteButton ;
myDeleteButton = (LinkButton)myTableCellControls[];
myDeleteButtonAttributesAdd(onclickreturn confirm(您是否确定要删除这条信息););
break;
default:
break;
}
}
点击表格行链接另一页
Code:
private void grdCustomer_ItemDataBound(object sender SystemWebUIWebControlsDataGridItemEventArgs e)
{
//点击表格打开
if (eItemItemType == ListItemTypeItem || eItemItemType == ListItemTypeAlternatingItem)
eItemAttributesAdd(onclickwindowopen(Defaultaspx?id= + eItemCells[]Text + ););
}
双击表格连接到另一页
在itemDataBind事件中
Code:
if(eItemItemType == ListItemTypeItem || eItemItemType == ListItemTypeAlternatingItem)
{
string orderItemID =emcells[]Text;
emAttributesAdd(ondblclick locationhref=/ShippedGridaspx?id= + orderItemID + );
}
双击表格打开新一页
Code:
if(eItemItemType == ListItemTypeItem || eItemItemType == ListItemTypeAlternatingItem)
{
string orderItemID =emcells[]Text;
emAttributesAdd(ondblclick open(/ShippedGridaspx?id= + orderItemID + ));
}
表格超连接列传递参数
Code:
<asp:HyperLinkColumn Target=_blank headertext=ID号 DataTextField=id NavigateUrl=aaaaspx?id=
<%# DataBinderEval(ContainerDataItem 数据字段)%> & name=<%# DataBinderEval(ContainerDataItem 数据字段)%> />
表格点击改变颜色
Code:
if (eItemItemType == ListItemTypeItem ||eItemItemType == ListItemTypeAlternatingItem)
{
eItemAttributesAdd(onclickthisstylebackgroundColor=#cc;
lor=buttontext;thisstylecursor=default;);
}
写在DataGrid的_ItemDataBound里
Code:
if (eItemItemType == ListItemTypeItem ||eItemItemType == ListItemTypeAlternatingItem)
{
eItemAttributesAdd(onmouseoverthisstylebackgroundColor=#cc;
lor=buttontext;thisstylecursor=default;);
eItemAttributesAdd(onmouseoutthisstylebackgroundColor=;lor=;);
}
关于日期格式
日期格式设定
Code:
DataFormatString={:yyyyMMdd}
我觉得应该在itembound事件中
emscell[你的列]text=DateTimeParse(emscell[你的列]textToString(yyyyMMdd))
Code:
获取错误信息并到指定页面
不要使用ResponseRedirect而应该使用ServerTransfer
eg
Code:
// in globalasax
protected void Application_Error(Object sender EventArgs e) {
if (ServerGetLastError() is HttpUnhandledException)
ServerTransfer(MyErrorPageaspx);
//其余的非HttpUnhandledException异常交给ASPNET自己处理就okay了 :)
}
Redirect会导致post-back的产生从而丢失了错误信息所以页面导向应该直接在服务器端执行这样就可以在错误处理页面得到出错信息并进行相应的处理
清空Cookie
Code:
CookieExpires=[DateTime];
ResponseCookies(UserName)Expires =
自定义异常处理
Code:
//自定义异常处理类
using System;
using SystemDiagnostics;
namespace MyAppException
{
/// <summary>
/// 从系统异常类ApplicationException继承的应用程序异常处理类
/// 自动将异常内容记录到Windows NT/的应用程序日志
/// </summary>
public class AppException:SystemApplicationException
{
public AppException()
{
if (ApplicationConfigurationEventLogEnabled)LogEvent(出现一个未知错误);
}
public AppException(string message)
{
LogEvent(message);
}
public AppException(string messageException innerException)
{
LogEvent(message);
if (innerException != null)
{
LogEvent(innerExceptionMessage);
}
}
//日志记录类
using System;
using SystemConfiguration;
using SystemDiagnostics;
using SystemIO;
using SystemText;
using SystemThreading;
namespace MyEventLog
{
/// <summary>
/// 事件日志记录类提供事件日志记录支持
/// <remarks>
/// 定义了个日志记录方法 (error warning info trace)
/// </remarks>
/// </summary>
public class ApplicationLog
{
/// <summary>
/// 将错误信息记录到Win/NT事件日志中
/// <param name=message>需要记录的文本信息</param>
/// </summary>
public static void WriteError(String message)
{
WriteLog(TraceLevelError message);
}
/// <summary>
/// 将警告信息记录到Win/NT事件日志中
/// <param name=message>需要记录的文本信息</param>
/// </summary>
public static void WriteWarning(String message)
{
WriteLog(TraceLevelWarning message);
}
/// <summary>
/// 将提示信息记录到Win/NT事件日志中
/// <param name=message>需要记录的文本信息</param>
/// </summary>
public static void WriteInfo(String message)
{
WriteLog(TraceLevelInfo message);
}
/// <summary>
/// 将跟蹤信息记录到Win/NT事件日志中
/// <param name=message>需要记录的文本信息</param>
/// </summary>
public static void WriteTrace(String message)
{
WriteLog(TraceLevelVerbose message);
}
/// <summary>
/// 格式化记录到事件日志的文本信息格式
/// <param name=ex>需要格式化的异常对象</param>
/// <param name=catchInfo>异常信息标题字符串</param>
/// <retvalue>
/// <para>格式后的异常信息字符串包括异常内容和跟蹤堆栈</para>
/// </retvalue>
/// </summary>
public static String FormatException(Exception ex String catchInfo)
{
StringBuilder strBuilder = new StringBuilder();
if (catchInfo != StringEmpty)
{
strBuilderAppend(catchInfo)Append(\r\n);
}
strBuilderAppend(exMessage)Append(\r\n)Append(exStackTrace);
return strBuilderToString();
}
/// <summary>
/// 实际事件日志写入方法
/// <param name=level>要记录信息的级别(errorwarninginfotrace)</param>
/// <param name=messageText>要记录的文本</param>
/// </summary>
private static void WriteLog(TraceLevel level String messageText)
{
try
{
EventLogEntryType LogEntryType;
switch (level)
{
case TraceLevelError:
LogEntryType = EventLogEntryTypeError;
break;
case TraceLevelWarning:
LogEntryType = EventLogEntryTypeWarning;
break;
case TraceLevelInfo:
LogEntryType = EventLogEntryTypeInformation;
break;
case TraceLevelVerbose:
LogEntryType = EventLogEntryTypeSuccessAudit;
break;
default:
LogEntryType = EventLogEntryTypeSuccessAudit;
break;
}
EventLog eventLog = new EventLog(Application ApplicationConfigurationEventLogMachineName ApplicationConfigurationEventLogSourceName );
//写入事件日志
eventLogWriteEntry(messageText LogEntryType);
}
catch {} //忽略任何异常
}
} //class ApplicationLog
}
Panel 横向滚动纵向自动扩展
Code:
<asp:panel ></asp:panel>
回车转换成Tab
()
Code:
<script language=javascript for=document event=onkeydown>
if(eventkeyCode== && eventsrcElementtype!=button && eventsrcElementtype!=submit && eventsrcElementtype!=reset && eventsrcElementtype!=&& eventsrcElementtype!=textarea);
eventkeyCode=;
</script>
() //当在有keydown事件的控件上敲回车时变为tab
Code:
public void Tab(SystemWeb UIWebControls WebControl webcontrol)
{
webcontrolAttributes Add (onkeydown if(eventkeyCode==) eventkeyCode=);
}
DataGrid超级连接列
Code:
DataNavigateUrlField=字段名 DataNavigateUrlFormatString=x?ID={}
DataGrid行随鼠标变色
Code:
private void DGzf_ItemDataBound(object sender SystemWebUIWebControlsDataGridItemEventArgs e)
{
if (eItemItemType!=ListItemTypeHeader)
{
eItemAttributesAdd( onmouseoutthisstylebackgroundColor=\+eItemStyle[BACKGROUNDCOLOR]+\);
eItemAttributesAdd( onmouseoverthisstylebackgroundColor=\+ #EFFF+\);
}
}
模板列
Code:
<ASP:TEMPLATECOLUMN visible=False sortexpression=demo headertext=ID>
<ITEMTEMPLATE>
<ASP LABEL text=<%# DataBinderEval(ContainerDataItem ArticleID)%> runat=server width=% id=lblColumn />
</ITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>
<ASP:TEMPLATECOLUMN headertext=选中>
<HEADERSTYLE wrap=False horiz></HEADERSTYLE>
<ITEMTEMPLATE>
<ASP:CHECKBOX id=chkExport runat=server />
</ITEMTEMPLATE>
<EDITITEMTEMPLATE>
<ASP:CHECKBOX id=chkExportON runat=server enabled=true />
</EDITITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>
后台代码
Code:
protected void CheckAll_CheckedChanged(object sender SystemEventArgs e)
{
//改变列的选定实现全选或全不选
CheckBox chkExport ;
if( CheckAllChecked)
{
foreach(DataGridItem oDataGridItem in MyDataGridItems)
{
chkExport = (CheckBox)oDataGridItemFindControl(chkExport);
chkExportChecked = true;
}
}
else
{
foreach(DataGridItem oDataGridItem in MyDataGridItems)
{
chkExport = (CheckBox)oDataGridItemFindControl(chkExport);
chkExportChecked = false;
}
}
}
数字格式化
Code:
【<%#ContainerDataItem(price)%>的结果是怎样格式化为?】
<%#ContainerDataItem(price{:¥###})%>
int i=;
string s=iToString(######);
日期格式化
【aspx页面内<%# DataBinderEval(ContainerDataItemCompany_Ureg_Date)%>
显示为 ::
我只想要 】
Code:
<%# DataBinderEval(ContainerDataItemCompany_Ureg_Date{:yyyyMd})%>
应该如何改?
【格式化日期】
取出来一般是
Code:
object((DateTime)objectFromDB)ToString(yyyyMMdd);
【日期的验证表达式】
A以下正确的输入格式 [] [ :: pm] [//]
^((\d{}(([][])|([][]))[\\/\s]?((((?[])|([]))[\\/\s]?((?[])|([][])|([])))|(((?[])|())[\\/\s]?((?[])|([][])|()))|(?[\\/\s]?((?[])|([][])))))|(\d{}(([][])|([][]))[\\/\s]?((((?[])|([]))[\\/\s]?((?[])|([][])|([])))|(((?[])|())[\\/\s]?((?[])|([][])|()))|(?[\\/\s]?((?[])|([])|([]))))))(\s(((?[])|([]))\:([][])((\s)|(\:([][])\s))([AM|PM|am|pm]{})))?$
B以下正确的输入格式[] [ ] [//]
^\d{}[\\/\s]?(((([])|([]))[\\/\s]?(([][])|([])))|((([])|())[\\/\s]?(([][])|()))|([\\/\s]?[][]))$
【大小写转换】
HttpUtilityHtmlEncode(string);
HttpUtilityHtmlDecode(string);
如何设定全局变量
Globalasax中
Application_Start()事件中
添加Application[属性名] = xxx;
就是你的全局变量
怎样作到HyperLinkColumn生成的连接后点击连接打开新窗口?
HyperLinkColumn有个属性Target将器值设置成_blank即可(Target=_blank)
【ASPNETMENU】点击菜单项弹出新窗口
在你的menuDataxml文件的菜单项中加入URLTarget=_blank如
Code:
<?xml version= encoding=GB?>
<MenuData ImagesBaseURL=images/>
<MenuGroup>
<MenuItem Label=内参信息 URL=Infomationaspx >
<MenuGroup ID=BBC>
<MenuItem Label=公告信息 URL=Infomationaspx URLTarget=_blank LeftIcon=filegif/>
<MenuItem Label=编制信息简报 URL=NewInfoaspx LeftIcon=filegif />
最好将你的aspnetmenu升级到版
读取DataGrid控件TextBox值
Code:
foreach(DataGrid dgi in yourDataGridItems)
{
TextBox tb = (TextBox)dgiFindControl(yourTextBoxId);
tbText
}
在DataGrid中有个模板列包含Textbox分别为 DG_ShuLiang (数量) DG_DanJian(单价) DG_JinE(金额)分别在列要求在录入数量及单价的时候自动算出金额即:数量*单价=金额还要求录入时限制为 数值型我如何用客户端脚本实现这个功能?
Code:
<asp:TemplateColumn HeaderText=数量>
<ItemTemplate>
<asp:TextBox id=ShuLiang runat=server Text=<%# DataBinderEval(ContainerDataItemDG_ShuLiang)%>
/>
<asp:RegularExpressionValidator id=revS runat=server C ErrorMessage=must be integer Validati />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText=单价>
<ItemTemplate>
<asp:TextBox id=DanJian runat=server Text=<%# DataBinderEval(ContainerDataItemDG_DanJian)%>
/>
<asp:RegularExpressionValidator id=revS runat=server C ErrorMessage=must be numeric Validati />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText=金额>
<ItemTemplate>
<asp:TextBox id=JinE runat=server Text=<%# DataBinderEval(ContainerDataItemDG_JinE)%> />
</ItemTemplate>
</asp:TemplateColumn><script language=javascript>
function DoCal()
{
var e = eventsrcElement;
var row = eparentNodeparentNode;
var txts = rowalltags(INPUT);
if (!txtslength || txtslength < )
return;
var q = txts[txtslength]value;
var p = txts[txtslength]value;
if (isNaN(q) || isNaN(p))
return;
q = parseInt(q);
p = parseFloat(p);
txts[txtslength]value = (q * p)toFixed();
}
</script>
datagrid选定比较底下的行时为什么总是刷新一下然后就滚动到了最上面刚才选定的行因屏幕的关系就看不到了
Code:
page_load
pagesmartNavigation=true
在Datagrid中修改数据当点击编辑键时数据出现在文本框中怎么控制文本框的大小 ?
Code:
private void DataGrid_ItemDataBound(obj senderDataGridItemEventArgs e)
{
for(int i=;i<eItemCellsCount;i++)
if(eItemItemType==ListItemTypeEditType)
{
eItemCellsAttributesAdd(Width px)
}
}
对话框
Code:
private static string ScriptBegin = <script language=\JavaScript\>;
private static string ScriptEnd = </script>;
public static void ConfirmMessageBox(string PageTargetstring Content)
{
string C+Content+);+if(retValue){windowlocation=+PageTarget+;};
ConfirmContent=ScriptBegin + ConfirmContent + ScriptEnd;
Page ParameterPage = (Page)SystemWebHttpContextCurrentHandler;
ParameterPageRegisterStartupScript(confirmConfirmContent);
//ResponseWrite
(strScript);
}
将时间格式化string aa=DateTimeNowToString(yyyy年MM月dd日);
取当前年月日时分秒
currentTime=SystemDateTimeNow;
取当前年
int 年= DateTimeNowYear;
取当前月
int 月= DateTimeNowMonth;
取当前日
int 日= DateTimeNowDay;
取当前时
int 时= DateTimeNowHour;
取当前分
int 分= DateTimeNowMinute;
取当前秒
int 秒= DateTimeNowSecond;
取当前毫秒
int 毫秒= DateTimeNowMillisecond;
.自定义分页代码
先定义变量
Code:
public static int pageCount; //总页面数
public static int curPageIndex=; //当前页面
下一页
if(DataGridCurrentPageIndex < (DataGridPageCount ))
{
DataGridCurrentPageIndex += ;
curPageIndex+=;
}
bind(); // DataGrid数据绑定函数
上一页
if(DataGridCurrentPageIndex >)
{
DataGridCurrentPageIndex += ;
curPageIndex=;
}
bind(); // DataGrid数据绑定函数
直接页面跳转
int a=intParse(JumpPageValueTrim());//JumpPageValueTrim()为跳转值
if(a<DataGridPageCount)
{
thisDataGridCurrentPageIndex=a;
}
bind();
.DataGrid使用
添加删除确认
Code:
private void DataGrid_ItemCreated(object sender SystemWebUIWebControlsDataGridItemEventArgs e)
{
foreach(DataGridItem di in thisDataGridItems)
{
if(diItemType==ListItemTypeItem||diItemType==ListItemTypeAlternatingItem)
{
((LinkButton)diCells[]Controls[])AttributesAdd(onclickreturn confirm(确认删除此项吗?););
}
}
}
样式交替
Code:
ListItemType itemType = eItemItemType;
if (itemType == ListItemTypeItem )
{
eItemAttributes[onmouseout] = javascript:thisstylebackgroundColor=#FFFFFF;;
eItemAttributes[onmouseover] = javascript:thisstylebackgroundColor=#dece;cursor=hand; ;
}
else if( itemType == ListItemTypeAlternatingItem)
{
eItemAttributes[onmouseout] = javascript:thisstylebackgroundColor=#adc;;
eItemAttributes[onmouseover] = javascript:thisstylebackgroundColor=#dece;cursor=hand; ;
}
添加一个编号列
Code:
DataTable dt= cExecuteRtnTableForAccess(sqltxt); //执行sql返回的DataTable
DataColumn dc=dtColumnsAdd(numberSystemTypeGetType(SystemString));
for(int i=;i<dtRowsCount;i++)
{
dtRows[number]=(i+)ToString();
}
DataGridDataSource=dt;
DataGridDataBind();
DataGrid中添加一个CheckBox页面中添加一个全选框
private void CheckBox_CheckedChanged(object sender SystemEventArgs e)
{
foreach(DataGridItem thisitem in DataGridItems)
{
((CheckBox)thisitemCells[]Controls[])Checked=CheckBoxChecked;
}
}
将当前页面中DataGrid显示的数据全部删除
Code:
foreach(DataGridItem thisitem in DataGridItems)
{
if(((CheckBox)thisitemCells[]Controls[])Checked)
{
string strloginid= DataGridDataKeys[thisitemItemIndex]ToString();
Del (strloginid); //删除函数
}
}
.当文件在不同目录下需要获取数据库连接字符串(如果连接字符串放在nfig然后在Globalasax中初始化)
在Application_Start中添加以下代码
Code:
Application[ConnStr]=thisContextRequestPhysicalApplicationPath+ConfigurationSettings
AppSettings[ConnStr]ToString();
. 变量ToString()
字符型转换 转为字符串
Code:
ToString(n); //生成
ToString(C); //生成 ¥
ToString(e); //生成 e+
ToString(f); //生成
ToString(x); //生成 (进制)
ToString(p); //生成 %
变量Substring(参数参数);
截取字串的一部分参数为左起始位数参数为截取几位 如string s = strSubstring();
.在自己的网站上登陆其他网站(如果你的页面是通过嵌套方式的话因为一个页面只能有一个FORM这时可以导向另外一个页面再提交登陆信息)
Code:
<SCRIPT language=javascript>
<!
function gook(pws)
{
frmsubmit();
}
//>
</SCRIPT> <body leftMargin= topMargin= marginwidth= marginheight=>
<form name=frm action= method=post>
<tr>
<td>
<input id=f_user type=hidden size= name=f_user runat=server>
<input id=f_domain type=hidden size= name=f_domain runat=server>
<input class=box id=f_pass type=hidden size= name=pwshow runat=server>
<INPUT id=lng type=hidden maxLength= size= value= name=lng>
<INPUT id=tem type=hidden size= value= name=tem>
</td>
</tr>
</form>
文本框的名称必须是你要登陆的网页上的名称如果源码不行可以用vsniffer 看看
下面是获取用户输入的登陆信息的代码
Code:
string name;
name=RequestQueryString[EmailName];
try
{
int a=nameIndexOf(@nameLength);
f_userValue=nameSubstring(a);
f_domainValue=nameSubstring(a+nameLength(a+));
f_passValue=RequestQueryString[Psw];
}
catch
{
ScriptAlert(错误的邮箱!);
ServerTransfer(indexaspx);
}
datagrid分页中如果删除时出现超出索引
Code:
public void jumppage(SystemWebUIWebControlsDataGrid dg)
{
int int_PageLess; //定义页面跳转的页数
//如果当前页是最后一页
if(dgCurrentPageIndex == dgPageCount)
{
//如果就只有一页
if(dgCurrentPageIndex == )
{
//删除后页面停在当前页
dgCurrentPageIndex = dgPageCount;
}
else
{
//如果最后一页只有一条记录
if((dgItemsCount % dgPageSize == ) || dgPageSize == )
{
//把最后一页最后一条记录删除后页面应跳转到前一页
int_PageLess = ;
}
else //如果最后一页的记录数大于那么在最后一页删除记录后仍然停在当前页
{
int_PageLess = ;
}
dgCurrentPageIndex = dgPageCount int_PageLess;
}
}
}
警告窗口
/**//// <summary>
/// 服务器端弹出alert对话框
/// </summary>
/// <param name=str_Message>提示信息例子不能为空!</param>
/// <param name=page>Page类</param>
Code:
public void Alert(string str_MessagePage page)
{
pageRegisterStartupScript(<script>alert(+str_Message+);</script>);
}
重载此警告窗口使某控件获得焦点
Code:
/**//// <summary>
/// 服务器端弹出alert对话框并使控件获得焦点
/// </summary>
/// <param name=str_Ctl_Name>获得焦点控件Id值比如txt_Name</param>
/// <param name=str_Message>提示信息例子请输入您姓名!</param>
/// <param name=page>Page类</param>
public void Alert(string str_Ctl_Namestring str_MessagePage page)
{
pageRegisterStartupScript(<script>alert(+str_Message+);documentforms()+str_Ctl_Name+focus(); documentforms()+str_Ctl_Name+select();</script>);
}
确认对话框
Code:
/**//// <summary>
/// 服务器端弹出confirm对话框
/// </summary>
/// <param name=str_Message>提示信息例子您是否确认删除!</param>
/// <param name=btn>隐藏Botton按钮Id值比如btn_Flow</param>
/// <param name=page>Page类</param>
public void Confirm(string str_Messagestring btnPage page)
{
pageRegisterStartupScript(<script> if (confirm(+str_Message+)==true){documentforms()+btn+click();}</script>);
}
重载确认对话框点击确定触发一个隐藏按钮事件点击取消触发一个隐藏按钮事件
Code:
/**//// <summary>
/// 服务器端弹出confirm对话框询问用户准备转向那些操作包括确定和取消时的操作
/// </summary>
/// <param name=str_Message>提示信息比如成功增加数据单击\确定\按钮填写流程单击\取消\修改数据</param>
/// <param name=btn_Redirect_Flow>确定按钮id值</param>
/// <param name=btn_Redirect_Self>取消按钮id值</param>
/// <param name=page>Page类</param>
public void Confirm(string str_Messagestring btn_Redirect_Flowstring btn_Redirect_SelfPage page)
{
pageRegisterStartupScript(<script> if (confirm(+str_Message+)==true){documentforms()+btn_Redirect_Flow+click();}else{documentforms()+btn_Redirect_Self+click();}</script>);
}
获得焦点
Code:
/**//// <summary>
/// 使控件获得焦点
/// </summary>
/// <param name=str_Ctl_Name>获得焦点控件Id值比如txt_Name</param>
/// <param name=page>Page类</param>
public void GetFocus(string str_Ctl_NamePage page)
{
pageRegisterStartupScript(<script>documentforms()+str_Ctl_Name+focus(); documentforms()+str_Ctl_Name+select();</script>);
}
子窗体返回主窗体
Code:
**////<summary>
///名称redirect
///功能子窗体返回主窗体
///参数url
///返回值空
///</summary>
public void redirect(string urlPage page)
{
if ( Session[IfDefault]!=(object)Default)
{
pageRegisterStartupScript(<script>windowtopdocumentlocation+url+;</script>);
}
}
判断是否为数字
Code:
/**//// <summary>
/// 名称IsNumberic
/// 功能判断输入的是否是数字
/// 参数string oText源文本
/// 返回值bool true:是false:否
/// </summary>
public bool IsNumberic(string oText)
{
try
{
int var=ConvertToInt (oText);
return true;
}
catch
{
return false;
}
}
获得字符串实际长度(包括中文字符)
Code:
//获得字符串oString的实际长度
public int StringLength(string oString)
{
byte[] strArray=SystemText EncodingDefault GetBytes (oString);
int res=strArrayLength ;
return res;
}