コードASP.NETを使用してContentPlaceHolderデータを設定する
-
08-07-2019 - |
質問
コードを使用してContentPlaceHolderにデータを設定することはできますか?これが私が考えていることです:
dim oCPH as new ContentPlaceHolder
oCPH.id = "column1" 'this id is the one that corresponds with the ID I set on the page
oCPH.content = "content here" '<-- not real code
明らかにそれは正しい構文ではありませんが、これが私が求めていることを明確にすることを願っています。
解決
現在のページのマスターページ要素を通じて参照できる必要があります。次のようなもの:
ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("column1");
マスターページのコードビハインドにある場合は、名前で参照するだけです。
所属していません StackOverflow