title: linkbutton click in jquery modal popup
body: <p>I have a repeater and in item template of that repeater I am having a button, when I click this button it opens another view.aspx page in jquery modal popup, upto now its working fine, but when I click a link button in view.aspx page(which is opened as a modal popup) then view.aspx automatically opening in normal mode(not in modal popup)</p>
  
  <p>Please Help me, Thank you in advance</p>
  
  <p>Images<img src="https://i.stack.imgur.com/3Ukth.png" alt="enter image description here"> </p>
  
  <p>In above image edukating(9) is a link button when I click this link button, it happens this way</p>
  
  <p><img src="https://i.stack.imgur.com/m5J0W.png" alt="enter image description here"></p>
  
  <p>I used the following code</p>
  
  <p>Code in repeater(only code which I used for popup):</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function CollectModalPopUp() {
          $(document).ready(function () {
              var mydiv = $('#mydiv');
              mydiv.dialog({ autoOpen: false });
              // Load the content using AJAX
              mydiv.load('ViewNoteTest.aspx');
              // Open the dialog
              mydiv.dialog('open');
  
              return false;
          });
      }
  &lt;/script&gt;
  
   &lt;div id="mydiv"&gt;
  
   &lt;/div&gt;
  </code></pre>
  
  <p>Code in button click event of repeater</p>
  
  <pre><code>objBalItem = new BalItem();
                  Session.Remove("dtAllTags");
                  Session.Remove("dtAllAddedTags");
                  int ItemId = Convert.ToInt32(e.CommandArgument.ToString().Split(',')[0].ToString());
                  //string Url = e.CommandArgument.ToString().Split(',')[2].ToString();
                  LstItemSuggestTags = new List&lt;BeSuggestedTag&gt;();
                  LstItemSuggestTags = objBalItem.GetItemTagSuggestions(ItemId);
                  Session["LstItemSuggestTags "] = LstItemSuggestTags;
                  Session["CommandArgument"] = e.CommandArgument.ToString();
                  Session["UserInContext"] = UserInContext;
                  string script = "&lt;script type=\"text/javascript\"&gt; CollectModalPopUp(); &lt;/script&gt;";
                  ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, false);
  </code></pre>
  
  <p>Code in ViewPageTest.aspx</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
          {
              if (Session["UserInfo"] != null)
              {
                  UserObj = new UserInfo();
                  UserObj = (UserInfo)Session["UserInfo"];
                  UserId = Convert.ToInt64(UserObj.Id);
              }
  
              if (Session["LstItemSuggestTags "] != null &amp;&amp; Session["CommandArgument"] != null)
              {
  
                  if (!IsPostBack)
                  {
                      LstItemSuggestTags = Session["LstItemSuggestTags "] as List&lt;BeSuggestedTag&gt;;
                      foreach (BeSuggestedTag ItemSuggestTags in LstItemSuggestTags)
                      {
                          if (!dtAllTags.Columns.Contains("TagId"))
                          {
                              dtAllTags.Columns.Add("TagId");
                          }
                          if (!dtAllTags.Columns.Contains("TagName"))
                          {
                              dtAllTags.Columns.Add("TagName");
                          }
                          drAllTags = dtAllTags.NewRow();
                          drAllTags["TagId"] = ItemSuggestTags.TagId.ToString();
                          drAllTags["TagName"] = ItemSuggestTags.TagName.ToString();
                          dtAllTags.Rows.Add(drAllTags);
  
  
                      }
                      Session["dtAllTags"] = dtAllTags;
                      //GenerateSuggestedTags();
                      //AddTags();
                  }
                  string CommandArgument = Session["CommandArgument"].ToString();
                  ItemId = Convert.ToInt64(CommandArgument.Split(',')[0].ToString());
                  lblTitleText.Text = CommandArgument.Split(',')[1].ToString();
                  lnkbtnUrl.Text = CommandArgument.Split(',')[2].ToString();
                  lnkbtnUrl.PostBackUrl = CommandArgument.Split(',')[2].ToString();
                  lblDescriptionText.Text = CommandArgument.Split(',')[3].ToString();
                  GenerateSuggestedTags();
                  AddTags();
              }
  
          }
  
          protected void GenerateSuggestedTags()
          {
              if (Session["dtAllTags"] != null)
              {
                  dtAllTags = Session["dtAllTags"] as DataTable;
                  pnlPopupSuggestedTags.Controls.Clear();
                  foreach (DataRow dr in dtAllTags.Rows)
                  {
                      Panel pnlRelateTags = new Panel();
                      pnlRelateTags.ID = "InnerRelatedTagspnl_" + dr["TagId"].ToString();
                      LinkButton lnkraltedTag = new LinkButton();
                      lnkraltedTag.ID = "lnkraltedTag_" + dr["TagId"].ToString();
                      ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(lnkraltedTag);
                      // pnlRelateTags.CssClass = "RelatedTags";
                      pnlRelateTags.ToolTip = "Include Tag";
                      pnlRelateTags.Style.Add("overflow", "hidden");
                      lnkraltedTag.Text = (dr["TagName"].ToString().Length &gt; 15 ? dr["TagName"].ToString().Substring(0, 15) : dr["TagName"].ToString());
                      lnkraltedTag.CommandArgument = dr["TagId"].ToString() + "," + dr["TagName"].ToString();
                      lnkraltedTag.Command += new CommandEventHandler(lnkraltedTag_Command);
                      lnkraltedTag.CssClass = "RelatedTags";
                      lnkraltedTag.EnableViewState = true;
                      lnkraltedTag.Style.Add("word-break", "break-word");
                      pnlRelateTags.Controls.Add(lnkraltedTag);
                      pnlPopupSuggestedTags.Controls.Add(pnlRelateTags);
                  }
              }
          }
  
          protected void lnkraltedTag_Command(object sender, CommandEventArgs e)
          {
              AddTagToPanel(e.CommandArgument.ToString());
          }
  
          private void AddTagToPanel(string commandArgument)
          {
              Int64 tagId = Convert.ToInt64(commandArgument.Split(',')[0].ToString());
              string tagName = commandArgument.Split(',')[1].ToString();
              if (Session["dtAllAddedTags"] != null)
              {
                  dtAddedTags = Session["dtAllAddedTags"] as DataTable;
              }
              if (!dtAddedTags.Columns.Contains("TagId"))
              {
                  dtAddedTags.Columns.Add("TagId");
              }
              if (!dtAddedTags.Columns.Contains("TagName"))
              {
                  dtAddedTags.Columns.Add("TagName");
              }
              drAddedTags = dtAddedTags.NewRow();
              drAddedTags["TagId"] = tagId;
              drAddedTags["TagName"] = tagName;
              dtAddedTags.Rows.Add(drAddedTags);
              dtAddedTags = RemoveDuplicateRows(dtAddedTags, "TagId");
              //foreach (DataRow dr in dtAddedTags.Rows)
              //{
              //    Panel pnlTag = pnlPopupSuggestedTags.FindControl("InnerRelatedTagspnl_" + dr["TagId"].ToString()) as Panel;
              //    pnlPopupSuggestedTags.Controls.Remove(pnlTag);
              //}
              Session["dtAllAddedTags"] = dtAddedTags;
             AddTags();
              dtAllTags = Session["dtAllTags"] as DataTable;
              foreach (DataRow drOuter in dtAddedTags.Rows)
              {
                  for (int i = dtAllTags.Rows.Count - 1; i &gt;= 0; i--)
                  {
                      DataRow drInner = dtAllTags.Rows[i];
                      if (drOuter["TagId"].ToString() == drInner["TagId"].ToString())
                      {
                          drInner.Delete();
                      }
                  }
              }
              Session["dtAllTags"] = dtAllTags;
              GenerateSuggestedTags();
          }
  
          public void AddTags()
          {
              if (Session["dtAllAddedTags"] != null)
              {
                  dtAddedTags = Session["dtAllAddedTags"] as DataTable;
                  pnlPopupTags.Controls.Clear();
                  foreach (DataRow row in dtAddedTags.Rows)
                  {
                      Panel pnl = new Panel();
                      pnl.ID = "Innerpnl_" + row["TagId"].ToString();
                      LinkButton lnkTag = new LinkButton();
                      lnkTag.ID = "lnkTag" + row["TagId"].ToString();
                      pnl.CssClass = "tags";
                      lnkTag.Text = row["TagName"].ToString();
                      lnkTag.CommandArgument = row["TagId"].ToString() + "," + row["TagName"].ToString();
                      lnkTag.Command += new CommandEventHandler(lnkTag_Command);
                      ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(lnkTag);
                      pnl.Controls.Add(lnkTag);
                      pnlPopupTags.Controls.Add(pnl);
                  }
              }
          }
  
          public DataTable RemoveDuplicateRows(DataTable dTable, string colName)
          {
              Hashtable hTable = new Hashtable();
              ArrayList duplicateList = new ArrayList();
  
              //Add list of all the unique item value to hashtable, which stores combination of key, value pair.
              //And add duplicate item value in arraylist.
              foreach (DataRow drow in dTable.Rows)
              {
                  if (hTable.Contains(drow[colName]))
                      duplicateList.Add(drow);
                  else
                      hTable.Add(drow[colName], string.Empty);
              }
  
              //Removing a list of duplicate items from datatable.
              foreach (DataRow dRow in duplicateList)
                  dTable.Rows.Remove(dRow);
  
              //Datatable which contains unique records will be return as output.
              return dTable;
          }
  
          protected void btnCancel_Click(object sender, EventArgs e)
          {
          }
  
          protected void lnkTag_Command(object sender, CommandEventArgs e)
          {
              DeleteTagFromPanel(e.CommandArgument.ToString());
          }
  
          protected void DeleteTagFromPanel(string commandArgument)
          {
              dtAllTags = Session["dtAllTags"] as DataTable;
              dtAddedTags = Session["dtAllAddedTags"] as DataTable;
              //foreach (DataRow dr in dtAddedTags.Rows)
              //{
              //    Panel pnlTag = pnlPopupTags.FindControl("Innerpnl_" + dr["TagId"].ToString()) as Panel;
              //    pnlPopupTags.Controls.Remove(pnlTag);
              //}
  
              Int64 tagId = Convert.ToInt64(commandArgument.Split(',')[0].ToString());
              string tagName = commandArgument.Split(',')[1].ToString();
              if (Session["dtAllTags"] != null)
              {
                  dtAllTags = Session["dtAllTags"] as DataTable;
              }
              if (!dtAllTags.Columns.Contains("TagId"))
              {
                  dtAllTags.Columns.Add("TagId");
              }
              if (!dtAllTags.Columns.Contains("TagName"))
              {
                  dtAllTags.Columns.Add("TagName");
              }
              drAllTags = dtAllTags.NewRow();
              drAllTags["TagId"] = tagId;
              drAllTags["TagName"] = tagName;
              dtAllTags.Rows.Add(drAllTags);
              foreach (DataRow drOuter in dtAllTags.Rows)
              {
                  for (int i = dtAddedTags.Rows.Count - 1; i &gt;= 0; i--)
                  {
                      DataRow drInner = dtAddedTags.Rows[i];
                      if (drOuter["TagId"].ToString() == drInner["TagId"].ToString())
                      {
                          drInner.Delete();
                      }
                  }
              }
              Session["dtAllTags"] = dtAllTags;
              Session["dtAllAddedTags"] = dtAddedTags;
              AddTags();
              GenerateSuggestedTags();
          }
  
          protected void btnSave_Click(object sender, EventArgs e)
          {
              Int64? UserInContext = Session["UserInContext"] as Int64?;
  
              dtAddedTags = Session["dtAllAddedTags"] as DataTable;
              if (!dtTagId.Columns.Contains("TagId"))
              {
                  dtTagId.Columns.Add("TagId");
              }
              if (dtTagId.Rows.Count &gt; 0)
              {
                  foreach (DataRow dr in dtAddedTags.Rows)
                  {
                      drTagId = dtTagId.NewRow();
                      drTagId["TagId"] = dr["TagId"].ToString();
                      dtTagId.Rows.Add(drTagId);
                  }
              }
              objBalItem = new BalItem();
             Int32 flag= objBalItem.CollectItem(ItemId, UserId, UserInContext, dtTagId);
             if (flag == 0)
             {
  
                 ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "CallJS", "ModalPopUpWithOKbutton();", true);
                 //string script = "&lt;script type=\"text/javascript\"&gt; HideModal(); &lt;/script&gt;";
                 //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "HideModal", script);
             }
             else if(flag == 1)
             {
                 //pmsg.InnerText = "Problem in collecting Item";
                 string script = "&lt;script type=\"text/javascript\"&gt; ModalPopUpWithOKbutton(); &lt;/script&gt;";
                 Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ModalPopUpWithOKbutton", script);
             }
          }
  </code></pre>