本文整理汇总了C#中Page.FindControl方法的典型用法代码示例。如果您正苦于以下问题:C# Page.FindControl方法的具体用法?C# Page.FindControl怎么用?C# Page.FindControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page.FindControl方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPostBackControl
public static Control GetPostBackControl(Page page)
{
Control postbackControlInstance = null;
string postbackControlName = page.Request.Params.Get("__EVENTTARGET");
if (postbackControlName != null && postbackControlName != string.Empty)
{
postbackControlInstance = page.FindControl(postbackControlName);
}
else
{
// handle the Button control postbacks
for (int i = 0; i < page.Request.Form.Keys.Count; i++)
{
postbackControlInstance = page.FindControl(page.Request.Form.Keys[i]);
if (postbackControlInstance is System.Web.UI.WebControls.Button)
{
return postbackControlInstance;
}
}
}
// handle the ImageButton postbacks
if (postbackControlInstance == null)
{
for (int i = 0; i < page.Request.Form.Count; i++)
{
if ((page.Request.Form.Keys[i].EndsWith(".x")) || (page.Request.Form.Keys[i].EndsWith(".y")))
{
postbackControlInstance = page.FindControl(page.Request.Form.Keys[i].Substring(0, page.Request.Form.Keys[i].Length - 2));
return postbackControlInstance;
}
}
}
return postbackControlInstance;
}
示例2: GetPostBackControl
public static Control GetPostBackControl(Page thePage)
{
Control myControl = null;
string ctrlName = thePage.Request.Params.Get("__EVENTTARGET");
if (((ctrlName != null) & (ctrlName != string.Empty)))
{
myControl = thePage.FindControl(ctrlName);
}
else
{
foreach (string Item in thePage.Request.Form)
{
Control c = thePage.FindControl(Item);
if (((c) is System.Web.UI.WebControls.Button))
{
myControl = c;
}
}
}
return myControl;
}
示例3: GetPostBackControl
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
public static Control GetPostBackControl(Page page)
{
Control control = null;
string ctrlname = page.Request.Params.Get("__EVENTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
{
control = page.FindControl(ctrlname);
}
else
{
foreach (string ctl in page.Request.Form)
{
Control c = page.FindControl(ctl);
if (c is System.Web.UI.WebControls.Button)
{
control = c;
break;
}
}
}
return control;
}
示例4: SetFocus
public void SetFocus(Page sPage)
{
string[] sCtrl = null;
string sCtrlId = null;
Control sCtrlFound = default(Control);
string sCtrlClientId = null;
string sScript = null;
sCtrl = sPage.Request.Form.GetValues("__EVENTTARGET");
if ((sCtrl != null))
{
sCtrlId = sCtrl[0];
sCtrlFound = sPage.FindControl(sCtrlId);
if ((sCtrlFound != null))
{
sCtrlClientId = sCtrlFound.ClientID;
sScript = "<SCRIPT language='javascript'>document.getElementById('" + sCtrlClientId + "').focus(); if (document.getElementById('" + sCtrlClientId + "').scrollIntoView(false)) {document.getElementById('" + sCtrlClientId + "').scrollIntoView(true)} </SCRIPT>";
sPage.ClientScript.RegisterStartupScript(typeof(string), "controlFocus", sScript);
}
}
}
示例5: SetPageDefaults
public static void SetPageDefaults(Page page)
{
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
DataSet dsAds = new DataSet();
if (HttpContext.Current.Cache["Ads"] == null)
{
AdsBL objAds = new AdsBL();
dsAds = objAds.GetAds();
HttpContext.Current.Cache["Ads"] = dsAds;
}
else
{
dsAds = (DataSet)HttpContext.Current.Cache["Ads"];
}
HtmlGenericControl div88X720 = (HtmlGenericControl)page.FindControl("div88X720");
HtmlGenericControl div250X250 = (HtmlGenericControl)page.FindControl("div250X250");
HtmlGenericControl div120X600 = (HtmlGenericControl)page.FindControl("div120X600");
if (dsAds.Tables[0].Rows.Count > 0)
{
DataView dv = new DataView();
DataTable dt = new DataTable();
dv = dsAds.Tables[0].DefaultView;
if (div88X720 != null)
{
dv.RowFilter = "AdName='div88X720'";
dt = dv.ToTable();
div88X720.InnerHtml= dt.Rows[0]["AdSource"].ToString() ;
dv.RowFilter = "";
}
if (div250X250 != null)
{
dv.RowFilter = "AdName='div250X250'";
dt = dv.ToTable();
div250X250.InnerHtml = dt.Rows[0]["AdSource"].ToString();
dv.RowFilter = "";
}
if (div120X600 != null)
{
dv.RowFilter = "AdName='div120X600'";
dt = dv.ToTable();
div120X600.InnerHtml = dt.Rows[0]["AdSource"].ToString();
dv.RowFilter = "";
}
}
//div.InnerHtml
//HtmlGenericControl , HtmlGenericControl div250X250
}
示例6: TagBinding
/// <summary>
/// ���ɱ�ǩģ�� + ����ֵ
/// </summary>
protected void TagBinding(Page page, List<Literal> lits, ITableImplement valObj, ITableImplement condObj, List<ITableImplement> listObj)
{
//isModule = true;
Content c1 = (Content)(page.FindControl("Content2"));
Literal Lit_Finder = (Literal)(page.FindControl("Lit_Finder"));
foreach (Literal lit in lits)
{
if (lit == null)
continue;
if (lit.ID == "Lit_Finder")
{
string old1 = lit.Text;
lit.Text = new AgileFrame.Common.TF_TABLEHelper(conn).GetTemplate(old1, valObj, condObj);
lit.Text = new AgileFrame.Common.TF_TABLEHelper(conn).GetHTML(lit.Text, condObj);
}
else if (lit.ID == "Lit_ListHeader")
{
string old1 = lit.Text;
lit.Text = new AgileFrame.Common.TF_TABLEHelper(conn).GetTemplate(old1, valObj);
lit.Text = new AgileFrame.Common.TF_TABLEHelper(conn).GetHTML(lit.Text, valObj);
}
else if (lit.ID == "Lit_RepList")
{
string old1 = lit.Text;
if (listObj.Count > 0)
{
lit.Text = new AgileFrame.Common.TF_TABLEHelper(conn).GetTemplate(old1, listObj[0]);
lit.Text = new AgileFrame.Common.TF_TABLEHelper(conn).GetHTML(lit.Text, listObj);
}
else
lit.Text = "";
}
else
{
string old1 = lit.Text;
lit.Text = new AgileFrame.Common.TF_TABLEHelper(conn).GetTemplate(old1, valObj);
lit.Text = new AgileFrame.Common.TF_TABLEHelper(conn).GetHTML(lit.Text, valObj);
}
}
}
示例7: GetControlThatCausedPostBack
private Control GetControlThatCausedPostBack(Page page)
{
//initialize a control and set it to null
Control ctrl = null;
//get the event target name and find the control
string ctrlName = Page.Request.Params.Get("__EVENTTARGET");
if (!String.IsNullOrEmpty(ctrlName))
ctrl = page.FindControl(ctrlName);
//return the control to the calling method
return ctrl;
}
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
m_id = this.ClientID;
m_page = this.Page;
// find the map control
if (m_mapBuddyId == null || m_mapBuddyId.Length == 0) m_mapBuddyId = "Map1";
m_map = m_page.FindControl(m_mapBuddyId) as Map;
// find the map resource manager
m_resourceManger = m_page.FindControl(m_map.MapResourceManager) as MapResourceManager;
m_callbackInvocation = m_page.ClientScript.GetCallbackEventReference(this, "argument", "processCallbackResult", "context", true);
}
示例9: RaiseCallbackEvent
public virtual string RaiseCallbackEvent(string requestString)
{
// break out the responseString into a querystring
Array keyValuePairs = requestString.Split("&".ToCharArray());
NameValueCollection m_queryString = new NameValueCollection();
m_page = this.Page;
Map map = m_page.FindControl(this.m_mapBuddyId) as Map;
string[] keyValue;
string response = "";
if (keyValuePairs.Length > 0)
{
for (int i = 0; i < keyValuePairs.Length; i++)
{
keyValue = keyValuePairs.GetValue(i).ToString().Split("=".ToCharArray());
m_queryString.Add(keyValue[0], keyValue[1]);
}
}
else
{
keyValue = requestString.Split("=".ToCharArray());
if (keyValue.Length > 0)
m_queryString.Add(keyValue[0], keyValue[1]);
}
// isolate control type and mode
string controlType = m_queryString["ControlType"];
string eventArg = m_queryString["EventArg"];
if (controlType == null) controlType = "Map";
switch (controlType)
{
case "Map":
// request is for the map control
string vectorMode = m_queryString["VectorMode"];
if (vectorMode != null && vectorMode.ToLower() == "measure")
{
response = ProcessMeasureRequest(m_queryString);
}
break;
default:
//
break;
}
return response;
}
示例10: addPageInfoChange
public static void addPageInfoChange(Page cp, String pageName)
{
if (cp != null)
{
try
{
HtmlForm form1 = (HtmlForm)cp.FindControl("form1");
switch (pageName)
{
case "ActivityForm":
if (form1 != null)
{
RadMultiPage rmp = (RadMultiPage)form1.FindControl("RadMultiViewActivity");
PageView pv1 = (PageView)rmp.FindControl("PgViewActivity");
foreach (Control childCtrl in pv1.Controls)
{
if (childCtrl is TextBox)
{
//Response.write("Requiredfieldvalidator<br>")
((TextBox)childCtrl).Attributes.Add("onChange", "pageInfoChanged('" + childCtrl.ClientID + "')");
}
if (childCtrl is DropDownList )
{
//Response.write("Requiredfieldvalidator<br>")
((DropDownList)childCtrl).Attributes.Add("onChange", "pageInfoChanged()");
}
if (childCtrl is CheckBoxList)
{
CheckBoxList cbl = (CheckBoxList)childCtrl;
cbl.Attributes.Add("onClick", "pageInfoChanged('cbl')");
}
if (childCtrl is RadGrid)
{
RadGrid grid = (RadGrid)childCtrl;
for (int i = 0; i < grid.Items.Count; i++ )
{
TextBox txt_Funds = (TextBox) grid.Items[i].FindControl("txt_Funds");
if (txt_Funds != null)
txt_Funds.Attributes.Add("onChange", "pageInfoChanged()");
}
}
}
}
break;
case "ActivityEquipment":
if (form1 != null)
{
RadMultiPage rmp = (RadMultiPage) form1.FindControl("RadMultiViewActivity");
PageView pv1 = (PageView)rmp.FindControl("PgViewActivity");
foreach (Control childCtrl in pv1.Controls)
{
if (childCtrl is TextBox)
{
//Response.write("Requiredfieldvalidator<br>")
((TextBox)childCtrl).Attributes.Add("onChange", "pageInfoChanged()");
}
if (childCtrl is DropDownList)
{
//Response.write("Requiredfieldvalidator<br>")
((DropDownList)childCtrl).Attributes.Add("onChange", "pageInfoChanged()");
}
if (childCtrl is CheckBoxList)
{
CheckBoxList cbl = (CheckBoxList)childCtrl;
lp_local_plan lpObj = new lp_local_plan();
lpObj.LoadByPrimaryKey(Convert.ToInt32(cp.Session[cp.Session.SessionID + "PlanID"].ToString()));
string roleid = cp.Session[cp.Session.SessionID + "roleid"].ToString();
switch (lpObj.Key_local_plan_level_id.ToString())
{
case "101":
switch (roleid)
{
case "103":
//CO Admin
cbl.Attributes.Add("onClick", "pageInfoChanged('cbl')");
break;
case "102":
//CAO
cbl.Attributes.Add("onClick", "pageInfoChanged('cbl')");
break;
case "101":
//SO Admin
cbl.Attributes.Add("onClick", "pageInfoChanged('cbl')");
break;
case "104":
//View Only
break;
//.........这里部分代码省略.........
示例11: LogError
//.........这里部分代码省略.........
using (conn = new MySqlConnection(_dsn))
{
using (mysql = new MySqlCommand(strSQL, conn))
{
mysql.Parameters.Add("?Message", MySqlDbType.VarChar, 250).Value = "SendMail";
mysql.Parameters.Add("?Page", MySqlDbType.VarChar, 500).Value = "SendMail";
mysql.Parameters.Add("?FullErrorText", MySqlDbType.VarChar, 500).Value = FullErrorText;
mysql.Parameters.Add("?ErrorDate", MySqlDbType.DateTime).Value = DateTime.Now;
conn.Open();
mysql.ExecuteNonQuery();
}
}
}
else if (_storage == StorageType.SQLServer)
{
strSQL = @" INSERT INTO [Errors]
(Message,
Page,
FullErrorText,
ErrorDate )
VALUES (@Message,
@Page,
@FullErrorText,
@ErrorDate ) ";
sql = new SqlServer();
p = new IDataParameter[4];
p[0] = sql.GetParameter("@Message", "SendMail");
p[1] = sql.GetParameter("@Page", "SendMail");
p[2] = sql.GetParameter("@FullErrorText", FullErrorText);
p[3] = sql.GetParameter("@ErrorDate", DateTime.Now.ToString());
sql.ExecuteNonQuery(_dsn, System.Data.CommandType.Text, strSQL, p);
}
else if (_storage == StorageType.MySQL)
{
try
{
strSQL = @"INSERT INTO errors
(ID,
Message,
Page,
FullErrorText,
ErrorDate)
VALUES (?ID,
?Message,
?Page,
?FullErrorText,
?ErrorDate) ";
conn = new MySqlConnection(_dsn);
mysql = new MySqlCommand(strSQL, conn);
Guid errorID = Guid.NewGuid();
mysql.Parameters.Add("?ID", MySqlDbType.VarChar, 36).Value = errorID;
mysql.Parameters.Add("?Message", MySqlDbType.VarChar, 250).Value = "SendMail";
mysql.Parameters.Add("?Page", MySqlDbType.VarChar, 250).Value = "SendMail";
mysql.Parameters.Add("?FullErrorText", MySqlDbType.VarChar, 7000).Value = FullErrorText;
mysql.Parameters.Add("?ErrorDate", MySqlDbType.DateTime).Value = DateTime.Now.ToString();
conn.Open();
mysql.ExecuteNonQuery();
}
finally
{
conn.Close();
}
}
else if (_storage == StorageType.File)
WriteErrorToLogFile(FullErrorText);
/*catch (Exception ex2)
{
FullErrorText += WriteHeading("Exception occurred (DatabaseType="+ _database +")");
FullErrorText += WriteValue("Database insertion could not be completed due to exception:");
FullErrorText += WriteValue(ex2.ToString());
FullErrorText += WriteHeading("strSQL");
FullErrorText += WriteValue(strSQL);
}*/
if (isSendErrorMail && !String.IsNullOrEmpty(smtpServer))
{
//'-- Send error e-mail to ErrorEmailRecipient:
Mailer mailer = new Mailer();
mailer.SendMail(senderEmail, senderName, recipientEmail, recipientName, "ERROR [" + applicationName + "] occured at " + DateTime.Now, FullErrorText, true, smtpServer);
}
if (showCustomErrorMessageOnPage)
{
Literal error = (Literal)page.FindControl("litError");
if (error != null)
{
error.Text += "<br /><div style='border:1px solid red; width:90%'>" + FullErrorText + "</div>";
error.Visible = true;
}
}
}
示例12: LoadPageFromProfile
internal void LoadPageFromProfile(Page p_page)
{
foreach (string controlID in this.ControlProfiles.Keys)
{
ControlProfile controlProfile = this.ControlProfiles[controlID] as ControlProfile;
controlProfile.LoadControlFromProfile(p_page.FindControl(controlID));
}
}
示例13: ExtractProfileFromPage
internal void ExtractProfileFromPage(Page p_page)
{
foreach (string controlID in this.ControlProfiles.Keys)
{
ControlProfile controlProfile = this.ControlProfiles[controlID] as ControlProfile;
controlProfile.ExtractProfileFromControl(p_page.FindControl(controlID));
}
}