VSNET开发中的小技巧Word格式.docx
- 文档编号:18787702
- 上传时间:2023-01-01
- 格式:DOCX
- 页数:38
- 大小:32.49KB
VSNET开发中的小技巧Word格式.docx
《VSNET开发中的小技巧Word格式.docx》由会员分享,可在线阅读,更多相关《VSNET开发中的小技巧Word格式.docx(38页珍藏版)》请在冰豆网上搜索。
server"
ID="
gvStatList"
AllowPaging="
false"
Width="
100%"
CssClass="
grid"
AutoGenerateColumns="
Visible="
true"
ShowFooter="
>
<
HeaderStyleCssClass="
grid-head"
/asp:
GridView>
.grid-head{
font-size:
14px;
font-weight:
normal;
color:
#FFFFFF;
background-image:
url(../images/grid-bg.gif);
text-align:
center;
vertical-align:
middle;
height:
28px;
互斥对象.很多情况下存在互斥对象,我通常这么处理
boolshowObject
...{
set...{
TextBox1.Visible=value;
TextBox2.Visible=!
value;
可以实现动态图片显示
%=str%>
后台代码
变量
变量=@<
imgsrc='
XXX'
onclick='
fucn(/)'
foreach(DataRowdr_ChildindsResult1.Tables[0].Rows)
if(!
Convert.ToBoolean(dr_Child["
FLAG"
]))
msiChild.sFontColor="
FontRed"
;
msiChild.BM=@"
/Images/NowPostion1.gif'
+msiChild.BM;
elseif(Convert.ToBoolean(dr_Child["
]))
/Images/submit.gif'
str+=msiChild.BM;
returnstr;
@"
+@"
br>
数据显示时
XXXXXXXXXXXXXX
XXXX
一列显示多条不同的数据
在改改就可以实现动态图片按扭并且每个按扭可以传不同的值出去
sBM+=i["
name"
].ToString()+@"
imgonclick='
DoPass("
+"
\"
+i["
ID"
].ToString()+"
)'
src='
Images/btnInfo.gif'
Style='
cursor:
hand'
)/>
这样+JS代码就是动态图片按扭
Asp.Net2.0中我们可以方便的访问配置文件中,.NetFrameWork2.0新增加了SystemWebSectionGroup类。
允许用户以编程方式访问配置文件的system.web组。
比如判断web.config内是否为debug="
或者判断身份验证形式
SystemWebSectionGroupws=newSystemWebSectionGroup();
CompilationSectioncp=ws.Compilation;
用cp.Debug;
就可以得到compilation节内关于"
debug"
的配置
AuthenticationSectionas=ws.Authentication;
用as.Mode可以获取authentication节中关于"
mode"
的配置,值为AuthenticationMode枚举之一
AuthenticationMode的取值如下:
成员名称说明
Forms将基于ASP.NET窗体的身份验证指定为身份验证模式。
None不指定身份验证。
Passport将MicrosoftPassport指定为身份验证模式。
Windows将Windows指定为身份验证模式。
在使用Internet信息服务(IIS)身份验证方法(基本、简要、集成Windows(NTLM/Kerberos)或证书)时适用此模式。
附:
SystemWebSectionGroup类的公共属性:
名称说明
AnonymousIdentification获取anonymousIdentification节。
Authentication获取authentication节。
Authorization获取authorization节。
BrowserCaps获取browserCaps节。
ClientTarget获取clientTarget节。
Compilation获取compilation节。
CustomErrors获取customErrors节。
Deployment获取deployment节。
DeviceFilters获取deviceFilters节。
Globalization获取globalization节。
HealthMonitoring获取healthMonitoring节。
HostingEnvironment获取hostingEnvironment节。
HttpCookies获取httpCookies节。
HttpHandlers获取httpHandlers节。
HttpModules获取httpModules节。
HttpRuntime获取httpRuntime节。
Identity获取identity节。
IsDeclarationRequired获取一个值,该值指示是否需要声明此ConfigurationSectionGroup对象。
(从ConfigurationSectionGroup继承。
)
IsDeclared获取一个值,该值指示是否已声明此ConfigurationSectionGroup对象。
(从ConfigurationSectionGroup继承。
MachineKey获取machineKey节。
Membership获取membership节。
MobileControls获取mobileControls节。
Name获取此ConfigurationSectionGroup对象的名称属性。
Pages获取pages节。
ProcessModel获取processModel节。
Profile获取profile节。
Protocols获取protocols节。
RoleManager获取roleManager节。
SectionGroupName获取与此ConfigurationSectionGroup关联的节组名称。
SectionGroups获取一个包含所有ConfigurationSectionGroup对象的ConfigurationSectionGroup对象,这些对象是此ConfigurationSectionGroup对象的子对象。
Sections获取一个ConfigurationSectionCollection,它包含此ConfigurationSectionGroup中的所有ConfigurationSection对象。
SecurityPolicy获取securityPolicy节。
SessionState获取sessionState节。
SiteMap获取siteMap节。
Trace获取trace节。
Trust获取trust节。
Type获取或设置此ConfigurationSectionGroup对象的类型。
UrlMappings获取urlMappings节。
WebControls获取webControls节。
WebParts获取webParts节。
WebServices获取webServices节。
XhtmlConformance获取xhtmlConformance节。
========================================
C#code
///<
summary>
///显示消息提示对话框,并进行页面跳转
///<
/summary>
paramname="
page"
当前页面指针,一般为this<
/param>
msg"
提示信息<
url"
跳转的目标URL<
publicstaticvoidShowAndRedirect(System.Web.UI.Pagepage,stringmsg,stringurl)
StringBuilderBuilder=newStringBuilder();
Builder.Append("
scriptlanguage='
javascript'
defer>
Builder.AppendFormat("
alert('
{0}'
msg);
top.location.href='
url);
/script>
//page.RegisterStartupScript("
message"
Builder.ToString());
page.ClientScript.RegisterStartupScript(page.GetType(),"
=====================================
假设这样一种模型,显示用GridView,数据源用DataSet。
每次获取10条信息,按每页10条分页。
有的时候数据可能不足10条,而客户要求不足10条显示为空行,以下代码解决了这个问题。
privateDataTableFillBlank(intpageSize,DataTabledt)
if(dt.Rows.Count<
pageSize)
for(inti=dt.Rows.Count-1;
i<
pageSize;
i++)
DataRowdr=dt.NewRow();
dt.Rows.Add(dr);
returndt;
privatevoidBindGrid(DataTabledt)
GridView.DataSource=dt;
GridView.DataBind();
===============================================
给大家一个很[color=#008000]COOL的例子吧。
有的时候我们想把网页动起来,我们希望页面上的某些元素可以移动,称之为拖拽。
[/color]
原创
HTMLcode
%@PageLanguage="
C#"
AutoEventWireup="
CodeBehind="
Drag.aspx.cs"
Inherits="
Test.Drag"
%>
!
DOCTYPEhtmlPUBLIC"
-//W3C//DTDXHTML1.0Transitional//EN"
"
http:
//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
htmlxmlns="
//www.w3.org/1999/xhtml"
>
headrunat="
title>
UntitledPage<
/title>
scripttype="
text/javascript"
language="
javascript"
//为Number增加一个属性,判断当前数据类型是否是数字
Number.prototype.NaN0=function(){returnisNaN(this)?
0:
this;
//全局变量
variMouseDown=false;
vardragObject=null;
//获得鼠标的偏移量(对象2-对象1)
functiongetMouseOffset(target,ev)
ev=ev||window.event;
vardocPos=getPosition(target);
varmousePos=mouseCoords(ev);
return{x:
mousePos.x-docPos.x,y:
mousePos.y-docPos.y};
//获得事件发生的实际位置----------------------对象1
functiongetPosition(e)
varleft=0;
vartop=0;
//相对位置累加得到实际位置
while(e.offsetParent)
left+=e.offsetLeft+(e.currentStyle?
(parseInt(e.currentStyle.borderLeftWidth)).NaN0():
0);
top+=e.offsetTop+(e.currentStyle?
(parseInt(e.currentStyle.borderTopWidth)).NaN0():
e=e.offsetParent;
left,y:
top};
//获得发生事件鼠标的位置----------------------对象2
functionmouseCoords(ev)
if(ev.pageX||ev.pageY)
ev.pageX,y:
ev.pageY};
ev.clientX+document.body.scrollLeft-document.body.clientLeft,y:
ev.clientY+document.body.scrollTop-document.body.clientTop};
//定义可以拖拽的对象
functionmakeDragable(item)
if(!
item)return;
//为可拖拽对象定义一个onmousedown事件的方法
ev=window.event;
item.onmousedown=function(ev)
dragObject=this;
mouseOffset=getMouseOffset(this,ev);
returnfalse;
//定义鼠标点下所调用的方法
functionmouseDown(ev)
vartarget=ev.target||ev.srcElement;
if(target.onmousedown||target.getAttribute('
DragObj'
))
}
//鼠标抬起后释放对象
functionmouseUp(ev)
dragObject=null;
//onmouseup事件触发时说明鼠标已经松开,所以设置down变量值为false
iMouseDown=false;
//鼠标移动
functionmouseMove(ev)
vartarget=ev.target||ev.srcElement;
varmousePos=mouseCoords(ev);
if(dragObject)
if(dragObject.style)
//移动对象
dragObject.style.left=mousePos.x-mouseOffset.x;
dragObject.style.top=mousePos.y-mouseOffset.y;
//lMouseState=iMouseDown;
if(dragObject)returnfalse;
document.onmousedown=mouseDown;
document.onmousemove=mouseMove;
document.onmouseup=mouseUp;
functionmoveImg()
varimg1=document.getElementById('
img1'
makeDragable(img1);
/head>
bodyonload="
moveImg()"
formid="
form1"
runat="
div>
a.jpg"
id="
img1"
style="
position:
absolute;
left:
0px;
top:
/div>
/form>
/body>
/html>
=============================================================
inputtype="
file"
onchange="
javascript:
document.getElementById('
image'
).src=this.value"
/>
image"
src="
这样在选中要上传的图片时,就可以看见自己要上传的了
==========================================
================================
CodeFile="
20_解决刷新后回到顶部的问题.aspx.cs"
_20_解决刷新后回到顶部的问题"
MaintainScrollPositionOnPostback="
无标题页<
body>
啊啊<
br/>
br
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VSNET 开发 中的 技巧
![提示](https://static.bdocx.com/images/bang_tan.gif)