2009-08-12 10 views
0

SideBarTemplateを使用してOnItemDataBoundイベントを捕捉する方法については、ASP.Netのウィザードコントロールの外観をカスタマイズして遊んでいます。すべてかなり簡単です。私が今やりたいことは、レンダリングされたLinkBut​​tonのテキストを変更して、現在のステップのためにステップ名に ">>"のような名前を付けることです。ASP.NetウィザードのサイドバーテンプレートのLinkBut​​tonタイトルの設定

ので、SideBarListのための私のItemDataBoundイベントハンドラで、私は次のコードを持っている:

Dim stepCurrent As WizardStep = e.Item.DataItem 
    Dim linkCurrent As LinkButton = e.Item.FindControl("SideBarButton") 
    If Not stepCurrent Is Nothing Then 
     Trace.Write("SideBar", "Current Step = " & stepCurrent.Wizard.ActiveStep.Name) 
     Trace.Write("Sidebar", "Link Button = " & linkCurrent.Text) 
     linkCurrent.Enabled = False 
     If stepCurrent.Wizard.ActiveStepIndex = e.Item.ItemIndex Then 
      linkCurrent.Style.Add(HtmlTextWriterStyle.Color, "#000000") 
      linkCurrent.Style.Add(HtmlTextWriterStyle.FontWeight, "bold") 
      linkCurrent.Text.Insert(0, ">> ") 
     End If 
    End If 

しかし、私が見つけることであるトレース出力がlunkbuttonテキストの空の文字列を示しているが、スタイルを変更作業。

私は間違った場所にテキストを設定しようとしていますか?

おかげ

答えて

3

私はDataListコントロールにSelectedItemTemplateで 別のリンクボタンコントロールを追加し、SideBarButtonに見える=「fasle」を設定する理由である「SideBarButton」textプロパティを変更するにはどのような方法を見つけることができませんでした。 SelectedItemTemplateは、現在のウィザードステップのためにサイドバーに項目を表示するために使用されます。 OnItemDataBoundイベントで


    <ItemTemplate> 
     <asp:LinkButton ID="SideBarButton" runat="server"/> 
    </ItemTemplate> 
    <SelectedItemTemplate> 
     <asp:LinkButton ID="ActiveSideBarButton" runat="server"> 
     <asp:LinkButton Visible="false" ID="SideBarButton"unat="server"/> 
    </SelectedItemTemplate> 

よう

Dim stepCurrent As WizardStep = e.Item.DataItem 
If stepCurrent.Wizard.ActiveStepIndex = e.Item.ItemIndex Then 
    Dim linkCurrent As LinkButton = e.Item.FindControl("ActiveSideBarButton") 
    linkCurrent.Style.Add(HtmlTextWriterStyle.Color, "#000000") 
    linkCurrent.Style.Add(HtmlTextWriterStyle.FontWeight, "bold") 
    LinkCurrent.Text = stepCurrent.Title; 
    linkCurrent.Text.Insert(0, ">> ") 
End If 

何かSideBarButtonは、現在のステップのための理由は目に見える=「false」にのみActiveSideBarButtonでレンダリングされませんが、あなたが必要なパラメータでレンダリングされますか。

関連する問題