2016-12-13 8 views
0

작동하지 않습니다. 그것은 벌금을 생성하고 있습니다. 문제는 포스트 백에 있습니다. 메뉴의 동적 내용이 다시 게시 될 때 사라집니다. Pls는 포스트 백 메뉴를 다시 렌더링하는 방법을 알려줍니다.동적 HTML 5 메뉴는 내가 마스터 페이지의 pageload에 뒤에 코드에서 <strong>UL</strong>를 사용 <strong>HTML 5</strong><strong>메뉴</strong>를 생성하고 다시 게시

둘째 나는 ASP.net 메뉴를 사용하는 경우이 문제가
는 또한 PLS 나

<ul runat="server" id ="Menu"></ul> 

코드 뒤에 동적 메뉴에 대한 다른 모범 사례를 알려 발생하지 않는 이유를 알고 싶어 :

public void Page_Load(object sender, EventArgs e) 
{ 
    if (IsPostBack) 
    { 
     return; 
    } 
    try 
    { 
     if (Session["user"] == null || Request.QueryString["applicationID"] == null) 
     { 
      throw new Exception("Invalid Session. Please login again!"); 
     } 
     Application1 appRow = bal.GetApplication(ApplicationID)[0]; 
     PanelQuickJump.Visible = Boolean.Parse(Session["IsAdmin"].ToString()) && (TaskID == 9 || TaskID == 25 || TaskID == 33 || TaskID == 55) && (appRow.ApplicationClosed != true);    
     ImageButtonSearch.Attributes.Add("onclick", "window.open ('SearchPop.aspx',null,'scrollbars=yes, status= no, resizable = yes, toolbar=no,location=no,height = 700, width = 1200, left = 200, top= 200, screenx=10,screeny=600,menubar=no');"); 

     /* get task */ 
     activeTask = bal.GetActiveTask(ApplicationID, Employee.EmployeeID)[0]; 
     //applicant = employeeAdapter.GetApplicant(ApplicationID)[0]; 
     LabelTaskName.Text = activeTask.Task; 
     /* get menu items */ 
     List<TaskForm1> taskForms = bal.GetTaskFormByTask(activeTask.TaskID, activeTask.SubTaskID); 
      foreach (TaskForm1 row in taskForms) 
     { 
      li = new HtmlGenericControl("li"); 
      anchor = new HtmlGenericControl("a"); 
      string itemURL = row.Page + "?applicationID=" + ApplicationID;    
      if (row.Checkable == true) 
      { 
       string reqMenuItem = "<span style=\"color: #669900; font-weight: bold\">" + row.Title + "</span>"; 
       anchor.InnerText = reqMenuItem; 
       anchor.Attributes.Add("href", itemURL);         
      } 
      else 
      { 
       anchor.Attributes.Add("href", itemURL); 
       anchor.InnerText = row.Title ; 
      } 

      if (row.Page == CurrentPageName) 
      { 
       anchor.InnerText = row.Title ; 
      } 
      li.Controls.Add(anchor); 
      Menu.Controls.Add(li); 
} 
} 

답변

0

내 문제를 해결하는 유일한 솔루션입니다 (각 포스트 백마다 페이지를 다시 렌더링하십시오).

public void Page_Load(object sender, EventArgs e) 
{ 
// if (IsPostBack) 
// { 
// return; 
// } 

    try {   
if (Session["user"] == null || Request.QueryString["applicationID"] == null) 
    { 
     throw new Exception("Invalid Session. Please login again!"); 
    } 
    Application1 appRow = bal.GetApplication(ApplicationID)[0]; 
    PanelQuickJump.Visible = Boolean.Parse(Session["IsAdmin"].ToString()) && (TaskID == 9 || TaskID == 25 || TaskID == 33 || TaskID == 55) && (appRow.ApplicationClosed != true);    
    ImageButtonSearch.Attributes.Add("onclick", "window.open ('SearchPop.aspx',null,'scrollbars=yes, status= no, resizable = yes, toolbar=no,location=no,height = 700, width = 1200, left = 200, top= 200, screenx=10,screeny=600,menubar=no');"); 

    /* get task */ 
    activeTask = bal.GetActiveTask(ApplicationID, Employee.EmployeeID)[0]; 
    //applicant = employeeAdapter.GetApplicant(ApplicationID)[0]; 
    LabelTaskName.Text = activeTask.Task; 
    /* get menu items */ 
    List<TaskForm1> taskForms = bal.GetTaskFormByTask(activeTask.TaskID, activeTask.SubTaskID); 
     foreach (TaskForm1 row in taskForms) 
    { 
     li = new HtmlGenericControl("li"); 
     anchor = new HtmlGenericControl("a"); 
     string itemURL = row.Page + "?applicationID=" + ApplicationID;    
     if (row.Checkable == true) 
     { 
      string reqMenuItem = "<span style=\"color: #669900; font-weight: bold\">" + row.Title + "</span>"; 
      anchor.InnerText = reqMenuItem; 
      anchor.Attributes.Add("href", itemURL);         
     } 
     else 
     { 
      anchor.Attributes.Add("href", itemURL); 
      anchor.InnerText = row.Title ; 
     } 

     if (row.Page == CurrentPageName) 
     { 
      anchor.InnerText = row.Title ; 
     } 
     li.Controls.Add(anchor); 
     Menu.Controls.Add(li); 
} 
}