Reference ASP.NET Master Page Content
===================================================
(1)Add this tage in .aspx
===================================================
(1)Add this tage in .aspx
<%@ MasterType virtualpath="~/Masters/Master1.master" %>
void Page_Load() { // Gets a reference to a TextBox control inside // a ContentPlaceHolder ContentPlaceHolder mpContentPlaceHolder; TextBox mpTextBox; mpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); if(mpContentPlaceHolder != null) { mpTextBox = (TextBox) mpContentPlaceHolder.FindControl("TextBox1"); if(mpTextBox != null) { mpTextBox.Text = "TextBox found!"; } } // Gets a reference to a Label control that not in // a ContentPlaceHolder Label mpLabel = (Label) Master.FindControl("masterPageLabel"); if(mpLabel != null) { Label1.Text = "Master page label = " + mpLabel.Text; } }
(2)Adding cookie and read cookie
===================================================================
(a)Add cookie
=============
Response.Cookies.Remove("HomeSpecialtyorDoctorSearch");
HttpCookie cookie = new HttpCookie("HomeSpecialtyorDoctorSearch");
Response.Cookies.Add(cookie);
cookie.Values.Add("CityId", ddlCity.SelectedValue);
cookie.Values.Add("CityName", ddlCity.SelectedItem.Text);
(b)Read cookie
===============
HttpCookie cookie = Request.Cookies.Get("HomeSpecialtyorDoctorSearch"); if (cookie.Values["CityId"] != null) { appointmentTypeId = Convert.ToInt32(cookie.Values["CityId"]); }
(3)Cache
===========================================================
(a)Add cache
=============
if (HttpRuntime.Cache["HospitalsDataDDl"] == null)
{
hospitalList = _GetTransactionData.GetHospitalInformation();
if (hospitalList.Count > 0)
{
HttpRuntime.Cache["HospitalsDataDDl"] = hospitalList;
}
}
else
{
hospitalList = (List<RHospitalBO>)HttpRuntime.Cache["HospitalsDataDDl"];
}
(b)Remove cache
=================
HttpRuntime.Cache.Remove("HospitalsDataDDl");
No comments:
Post a Comment