اخواني لديا MasterPage
وUpdatePanel
وهذة محاولتي للبحث عن الكنترولز الى موجودة فى Ajax UpdatePanel الى هو اصلا داخل Content
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public class Class2 : System.Web.UI.Page
{
public class class2
{
//-------------------------------------------------------------------------
//FindControls In MasterPage (Content) ContentPlaceHolder
public Control FindChildControl(Control start, string id)
{
if (start != null)
{
Control foundControl;
foundControl = start.FindControl(id);
if (foundControl != null)
{
return foundControl;
}
foreach (Control c in start.Controls)
{
foundControl = FindChildControl(c, id);
{
if (c.GetType().ToString() == "System.Web.UI.UpdatePanel")
{
FindControlInsidUpdatePanel(c);
}
}
if (foundControl != null)
{
return foundControl;
}
}
}
return null;
}
//-------------------------------------------------------------------------
//Find Controls Insid Ajax UpdatePanel:-
public Control FindControlInsidUpdatePanel(Control root)
{
foreach (Control c in root.Controls)
{
if (c.GetType().ToString() == "System.Web.UI.WebControls.TextBox")
{
TextBox z = (TextBox)c;
z.Text = "";
}
}
return null;
}
}
}وهذا الكود داخل صفحة Default التابعة للمستر بيج
Partial Class Default1 Inherits System.Web.UI.Page Dim Temp As New Class1 'استدعاء الكلاس Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'دالة البحث عن الكنترولز هل صحيح Master.Parent ام هناك Contents Temp.FindChildControl(Master.Parent, "Content1") End Sub End Class