当前位置:开发者网络 >> 技术教程 >> .NET教程 >> Asp.Net开发 >> 内容
精彩推荐
分类最新教程
分类热点教程
  
个性设计ASP.NET应用程序的七大绝招 (2)
作者:未知
日期:2005-11-22
人气:
投稿:(转贴)
来源:未知
字体:
收藏:加入浏览器收藏
以下正文:
3. DataList使用不同风格的模板
这招也非常实用,你可以制作两个不同的模板或表现形式,分别以.ascx控件的形式保存,运行时根据某个条件动态的选择使用其中的一个模板,另外ScottGu认为ItemDataBound方法也可以定制你显示的表现,比如加亮某个元素或是加一个促销广告图等等。





  
Dim theme As String
theme = DropDownList1.SelectedValue

DataList1.ItemTemplate = Page.LoadTemplate(theme & ".ascx") ---Cool
DataList1.DataSource = DS
DataList1.DataBind()


4. 设置服务器端控件的焦点


Private Sub SetFocus(ByVal controlToFocus As Control)
Dim scriptFunction As New StringBuilder
Dim scriptClientId As String

scriptClientId = controlToFocus.ClientID
scriptFunction.Append("<script language='javascript'>")
scriptFunction.Append("document.getElementById('" & scriptClientId & "').focus();")
scriptFunction.Append("</script>")
RegisterStartupScript("focus", scriptFunction.ToString())
End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If (Page.IsPostBack = False) Then
SetFocus(TextBox1)
End If
End Sub

相关文章: