2008-10-10 6 views
5

के माध्यम से ContentPlaceHolder डेटा सेट करें कोड के माध्यम से ContentPlaceHolder में डेटा सेट करना संभव है?कोड एएसपी.NET

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 

जाहिर है कि सही सिंटैक्स नहीं है, मुझे आशा है कि यह स्पष्ट करता है कि मैं क्या पूछ रहा हूँ: यह है कि मैं क्या सोच रहा हूँ है।

उत्तर

6

आपको वर्तमान पृष्ठ पर मास्टरपेज तत्व के माध्यम से संदर्भित करने में सक्षम होना चाहिए। कुछ ऐसा:

ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("column1"); 

यदि मास्टरपेज कोडबेइंड में है, तो बस इसे नाम से संदर्भित करें।