我有一些這樣的代碼如下:能見度/標籤的隱形在
if {
this.showhide.ImageUrl = "../common/images/hide-icon.png";
this.showhide.AlternateText = "Hide SearchBar";
this.searchBar.Visible = false;
Session["showHideImage"] = "hide";
ScreenProjectSearch ProjSearch = CurrentProjectSearch;
lblTypeOfSearch.Text = "Search results are based on";
string typeOfSearch = string.Empty;
if (CurrentProjectSearch != null)
{
//lblTypeOfSearch.Text = "Search results are based on";
if (CurrentProjectSearch.IsFileName)
typeOfSearch += " Filename " + ProjSearch.TextSearch.Trim();
if (CurrentProjectSearch.IsDescription)
typeOfSearch += " Description " + ProjSearch.TextSearch.Trim();
if (CurrentProjectSearch.IsPartNumber)
typeOfSearch += " PartNumber " + ProjSearch.TextSearch.Trim();
if (CurrentProjectSearch.IsState)
{
if (CurrentProjectSearch.IsDevelopment)
typeOfSearch += " Development State ";
if (CurrentProjectSearch.IsValidation)
typeOfSearch += " Validation State ";
if (CurrentProjectSearch.IsValidationPendingApproval)
typeOfSearch += " ValidationPendingApproval State ";
if (CurrentProjectSearch.IsPilot)
typeOfSearch += " Pilot State ";
if (CurrentProjectSearch.IsFactory)
typeOfSearch += " Factory State ";
if (CurrentProjectSearch.IsCancel)
typeOfSearch += " Cancel State ";
}
if (CurrentProjectSearch.IsDate)
typeOfSearch += " Created Date From: " + ProjSearch.FromDate + " To: " + ProjSearch.ToDate;
if (CurrentProjectSearch.IsPromoteDate)
typeOfSearch += " Promoted Date From: " + ProjSearch.FromPromoteDate + " To: " + ProjSearch.ToPromoteDate;
if (CurrentProjectSearch.IsCreatedBy)
typeOfSearch += " Created By: " + ProjSearch.CreatedBy.ToString();
if (CurrentProjectSearch.IsProjectIDs)
typeOfSearch += " PrjoectIds: " + ProjSearch.ProjectIDs;
if (CurrentProjectSearch.IsWorkFlow)
{
if (CurrentProjectSearch.IsMdiagsNormal)
typeOfSearch += " WorkFlow: " + "Mdiags Normal";
if (CurrentProjectSearch.IsMdiagsTestEngineer)
typeOfSearch += " WorkFlow: " + "Mdiags TestEngineer";
}
if (!string.IsNullOrEmpty(typeOfSearch))
{
lblTypeOfSearch.Text += typeOfSearch;
lblTypeOfSearch.Visible = true;
}
}
}
我想如果一些文本追加到它時,typeOfSearch
不爲空,在Page_Load
顯示此lblTypeOfSearch
。如果我檢查Page_Load
中的值,它在那裏顯示爲空。我怎樣才能利用這個變量來顯示?
只是調試巨獸,看看實際發生了什麼... – walther 2014-09-06 08:29:24
此代碼是在按鈕單擊。標籤在按鈕點擊事件中添加文本。如果我想再次使用相同的文本,我如何在頁面加載方法中使用它? – user3356020 2014-09-06 08:42:38