There are several ways of doing this but you can try
private void Button_Click(object sender, System.EventArgs e)
{
var boxes=new List<TextBox>();
FindControls(productList,boxes,"id2box");
foreach (TextBox box in boxes)
{
Response.Write(box.Text);
}
}
void FindControls(System.Web.UI.Control start, List<TextBox> result,string id)
{
foreach (System.Web.UI.Control item in start.Controls)
{
if (item is TextBox && (item as TextBox).ID==id)
result.Add(item as TextBox);
FindControls(item, result,id);
}
}
Hi,
thanks for the reply.But my pagelist is like
<EPiServer:PageList runat="server" ID="productList" >
<ItemTemplate>
<tbody>
<tr>
<td><img src='<%# GetImageURL(((EPiServer.Core.PageData)Container.DataItem).PropertyValue<string>("ProductID")) %>' alt=""></td>
<td width="20"><h4><a href="<%#Eval("LinkURL") %>"><%# Container.CurrentPage.PageName %></a></h4>
<%# Container.CurrentPage.Property["MarketingName"].Value %>
</td>
<td>Määrä<asp:TextBox ID="txtFirstName" runat="server" ></asp:TextBox>
<td><asp:LinkButton runat="server" class="remove" Text="Poista" OnCommand="removeProduct" CommandArgument="<%# Container.CurrentPage.PageLink %>"></asp:LinkButton>
</td>
</tr>
</tbody>
</ItemTemplate>
</EPiServer:PageList
along with the value of text I also know it is bounded to whichPagelink "Container.CurrentPage.PageLink"?
You have several options here. The quick fix is to add
<asp:TextBox ID="txtFirstName" runat="server" ToolTip="<%# Container.CurrentPage.PageLink %>" />
other methods could be to have an Literal that is visible=false with the pagelink. Then find all Literals with the same method
or to change the id on the textbox to have the pageID
but you could also add it to your link button the same way you add the page link
<asp:LinkButton runat="server" class="remove" Text="Poista" OnCommand="removeProduct" CommandArgument="<%# Container.CurrentPage.PageLink %>_<%#Container.FindControl("txtFirstName").UniqueID %>"></asp:LinkButton>
hey thanks for the reply
when I tried to add the pageID as a Id in the textbox. The textbox started dissappear from my page. I cant use tooltip because its showing up.Please suggest is there any other way to do so?
Hi I have a episerver pagelist showing the name of page and textbox field which is editable. Then I have a button in my page which is not inside the pagelist. onclick of this button i want all the values of the textbox. I am trying
private void Button_Click(object sender, System.EventArgs e)
{
foreach (PageList item in productList)
{
Response.Write(((TextBox)item.Controls[1]).Text);
}
where productList is the id of the pageList. But dosnt work.Please help