How to pass custom value to asp.net control on aspx page? - asp.net

I need to generate the following in ASP.NET page. What's the best, easiest way to do that?
Simplified example. So to custom property I need to pass string which would include index (i) to the property of the control. I could do it from codebehind, but it would be simpler and easier if I could keep it in .aspx file.
<table>
<%
for( var i = 0; i < 10; i++ )
{
%><tr>
<td>
<cc1:CustomControl runat="server" CustomProperty="SomeText[<% i %>]"/>
</td>
</tr>
<% } %>
</table>
Essentially I need to pass a custom, not predetermined value to the asp.net control.

This probably won't work how you expect it to. Instead, add a place holder like this:
<table>
<asp:PlaceHolder id="RowPlaceHolder" runat="server" />
</table>
And then in your code behind:
for (int i = 0;i<10;i++)
{
var tr = new HTMLTableRow();
var td = new HTMLTableCell();
var Custom = (CustomControl)LoadControl("MyControl.ascx");
Custom.id="Custom" + i.ToString();
Custom.CustomProperty = "SomeText[" + i.ToString() + "]";
td.Controls.Add(Custom);
tr.Controls.Add(td);
RowPlaceHolder.Controls.Add(tr);
}
Going deeper, if the number 10 really is hard-coded, you'll find things much easier to deal with in the long run if you just go ahead and copy 10 entries for your control into the aspx markup manually. Dynamic controls in ASP.Net webforms are rife with pitfalls and gotchas.
If the number comes from some legitimate datasource, then you're likely better off actually using that datasource and binding it to a data control like a repeater.

<%= i %>
Should work for you.

You could rock out with a repeater and use the Container.ItemIndex,
<asp:Repeater ID="rpt" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<cc1:CustomControl runat="server" CustomProperty="SomeText[<%# Container.ItemIndex %>]"/>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

Related

how to bind memory stream to asp.net image controls with out using image url

We have a new requirement to show the signature image in result grid for each record. Currently we store the signature image as base64 format in our database .we are able to convert base 64 to memory stream.
We want to understand does any of your image control support to bind image from memory stream instead of Url .
You could keep images as base64 string form, and use data url.
The following is a example.
<asp:Image runat="server" ID="myImage" />
The code behind is
this.myImage.ImageUrl = "data:image/png;base64,iVBORw0KGgo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MxB0ZN7n5RdxnBxNSGQM6FhDXZqwiHb3Eq0arBjyufHe+n8El3jqSomb6U4MdaFmZKPeiF7m12MMZXrjmrgOet40f3/JGCTwl84rmS1dMzwpF3AeZGAozVoddb6D33NhrpbhIc8UBdlY1hNZafG6w2/K5qb/beSgJ+zCVSIejjq/qvFQtGQeUtn3uIDFdhKXZEgwrl117WOcJMH3ClxpDt5KvAP8baAdKuXfPCzS3d7wPsS3t0e6KjEPiYg9O0Zv0lBxFLMV+Ce9oie8KR/AfN2KED1T7CQAAAAAElFTkSuQmCC";
The premise is that you need to know all the MIME type of images.
Reference: data URIs
Sure, you can do it this way.
A gridview, listview, repeater control - they can all do this.
So markup for a grid view:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Animal" HeaderText="Animal" ItemStyle-Width="200px"/>
<asp:TemplateField HeaderText="Picture">
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
Height="128px" Width="128px"
src='<%# "Data:Image/png;base64," + Eval("Image") %>'
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
And the code to load up the gridview would be:
protected void Page_Load(object sender, System.EventArgs e)
{
if (System.Web.UI.Page.IsPostBack == false)
LoadGrid();
}
public void LoadGrid()
{
using (SqlCommand cmdSQL = new SqlCommand("SELECT Animal, Image from tblAnimals",
new SqlConnection(My.Settings.TEST4)))
{
cmdSQL.Connection.Open();
GridView1.DataSource = cmdSQL.ExecuteReader;
GridView1.DataBind();
}
}
Results:
Now I used a direct eval expression - but you could also use the ItemDataBound event of the gridview (or list view).
Also, I did hard code the "mine" type in above (assumed .png). You often might want to consider to save the file/mine type as a extra column in the database. But, if the picture types are to be all the same types - then a hard code right in the expression as per above will work fine.
If you have a lot of columns for this grid, then I tend to switch over to listview, since each column does NOT need a template, and I find for quick and dirty - grid view is ok, but listview is better for tweaking and lots of customizing. The trick is to get Visual Studio to generate the template + markup, and then blow out all templates except for item template. When you do this, then the crazy truckload of markup is reduced down to "easy" levels. And you can then with greater ease drop in controls - and you don't have template them.
So, the same listview for above would be this:
<asp:ListView ID="ListView1" runat="server">
<ItemTemplate>
<tr style="">
<td><asp:Label ID="AnimalLabel" runat="server" Text='<%# Eval("Animal") %>' /></td>
<td>
<asp:Image ID="ImageT1" runat="server"
Height="128px" Width="128px"
src='<%# "Data:Image/png;base64," + Eval("Image") %>'
/>
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server" width="200">Animal</th>
<th runat="server">Image</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
So there is somewhat "more" markup, but you can with much greater ease drop in asp.net controls - and you don't have add a templatefield - (about 4 extra lines of markup for every column - so in the long run, I like the listview.
it looks quite much the same, like this:
And the behind code would be 100% the same as above.

ID of items in ASP.NET ListView is automatically extended

I have programmed a simple blog page - http://www.3don.net.br/Blog.aspx (another language, here only to show the structure). I want to use hashtags for pointing to the topics. For example, http://www.3don.net.br/Blog.aspx#19/04/16 should scroll the page to the topic created at 19/04/16.
However, I cannot get it!
The topics of the blog are ItemTemplates of a ListView control. When I define an ID="lblDatum" for the label control of the data of each topic (which is the first control of each topic), then this ID is modified by the NET machine to
id="ctl00_ContentPlaceHolder_lstBlog_ctrl0_ctl01_lblDatum" (you can see it in the source code of the page for the second topic, for example).
So, if I access in the browser www.3don.net.br/Blog.aspx#ctl00_ContentPlaceHolder_lstBlog_ctrl0_ctl01_lblDatum
the page indeed will scroll correctly. I can also programmatically change the ID for each topic differently and it still works for each topic.
However, the hashtag-name "ctl00_ContentPlaceHolder_lstBlog_ctrl0_ctl01_lblDatum" is not nice! Is there a possibility to suppress the ctl00_ContentPlaceHolder_lstBlog_ctrl0_ctl01_-part?
Or another idea for getting it?
Use ClientIdMode="Static" in your ListItem, which removes the autoGenerate ID, you got ID="lblDatum" on client.
ok, I added the clientIDMode="static" property to the Label control of the data:
<table id="table_intern" runat="server" >
<tr id="tr_intern" runat="server">
<td id="td_intern" runat="server">
<asp:Label ID="lblDatum" runat="server" Text='<%# Eval("data") %>' CssClass="rotfettschrift" clientidmode="static"/>
</td>
</tr>
<tr> ... </tr>
<tr> ... </tr>
</table>
... and, in code-behind, set the ID of this control of each topic igual of the text property of this control (the data):
lbl = CType(e.Item.FindControl("lblDatum"), Label)
lbl.ID = lbl.Text
However, the HTML-output is:
<tbody>
<tr id="ctl00_ContentPlaceHolder_lstBlog_ctrl0_ctl00_tr_intern">
<td id="ctl00_ContentPlaceHolder_lstBlog_ctrl0_ctl00_td_intern">
<span id="ctl00_ContentPlaceHolder_lstBlog_ctrl0_ctl00_19/05/16" class="rotfettschrift" clientidmode="static">19/05/16</span>
</td>
</tr>
<tr> ... </tr>
<tr> ... </tr>
</tbody>
Why is the ID of the span element ctl00_ContentPlaceHolder_lstBlog_ctrl0_ctl00_19/05/16 and not just 19/05/16 ???
Ok, i tested here, using reapeater, but with any other control works. You must set the id individually to each control, to make unique.
*I redid, using date.
MARKUP:
<table id="table_intern">
<asp:Repeater runat="server" ID="repeater" OnItemDataBound="repeater_ItemDataBound">
<ItemTemplate>
<tr>
<td>
<asp:Label Text="" runat="server" ID="label" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
BACKEND:
protected void Page_Load(object sender, EventArgs e)
{
var list = new List<string>();
for (int i = 0; i < 10; i++)
{
list.Add(string.Format("Item_{0}", i.ToString().PadLeft(2, '0')));
}
repeater.DataSource = list;
repeater.DataBind();
}
protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
var label = (Label)e.Item.FindControl("label");
var item = (DateTime)e.Item.DataItem;
label.ID = item.ToShortDateString();
label.Text = item.ToShortDateString();
label.ClientIDMode = ClientIDMode.Static;
}
}
RESULT:
<table id="table_intern">
<tbody><tr>
<td>
<span id="23/05/2016">23/05/2016</span>
</td>
</tr>
<tr>
<td>
<span id="24/05/2016">24/05/2016</span>
</td>
</tr>...
Sorry, for bad formatting, i will improve my answers if necessary.
Daniel,
thank you for dedicating your time.
You are defining the ClientIDMode property of the Label control in the code behind, ok. I do so, but I see that it does not work here:
screenshot
When I go with the mouse pointer over the ClientIDMode at the left it advices: "'ClientIDMode' is not a member of 'Label'"
and over the ClientIDMode at the right, it pops "'ClientIDMode' is not declared. It may be inaccessible due to its protection level."
Is there something undefined in my system?
Ok, i understand you using Framework2.0 in your project. Can you change Framework to 4.0 or upper? Otherwise you need use a .js approach, to scroll like wish.
ClientIdMode is from .net 4.0, how you have said .net4.6 installed, I assumed that the project was also 4.6.
IF, you can't change the version, you need use something like jquery to scroll. OR maybe a more hard solution creating a item in your itemTemplate like:
<span id='<%# Eval("data") %>'></span>
I don't have tested this solution, later I'll be testing;
Daniel,
I always suspected that, but the
"About Visual Studio" window tells another story.
Adicionally, in the registry I can find the v4/Full key and the Version information (at the right side) confirms the (installed and activated?) version 4.6.01055.
???
Or is framework v4 installed but not "activated"? Does this exist? Where can I see this?

Passing Params From Aspx

So I had have a table populating with data but I was wondering how I could pass two bits of data from a row depending on which link at the end of the row is clicked.
<%WebReceiptSummary[] receipts = GetReceipts();
if (receipts != null)
{
for (int i = 0; i < receipts.Length; i++)
{%>
<tr>
<td><%= receipts[i].Type%></td>
<td><%= receipts[i].PolicyNo%></td>
<td><%= receipts[i].Date%></td>
<td class="c"><%= receipts[i].Amount%></td>
<td class="r"><asp:LinkButton OnCommand="PDFLinkClick"
CommandArgument="<%= receipts[i].PDF %>&<% receipts[i].PolicyNo %>" runat="server">View PDF</asp:LinkButton></td>
</tr>
<% }
}
%>
Obviously my CommandArgument just passes back the string <%= receipts[i].PDF %>&<% receipts[i].PolicyNo %> not the values. What would be the best way of doing this? I was also thinking of using;
<asp:HiddenField ID="hiddenIsCaptchaReadyValidate" runat="server" Value=false/>
But I have the same problem here where the value is placed within quotes and also it means I need to create two hiddenfields for ever row which isn't the most efficient way of doing this. Thoughts?
It is not possible to have <%= %> commands as part of an attribute when added via the mark-up.
Can I recommend that instead of using the for loop in the ASPX, you instead use the <asp:Repeater> control? This will also allow you to set the CommandAttribute value from the code-behind.
An example...
<asp:Repeater runat="server" id="receipts" OnItemDataBound="receipts_ItemDataBound">
<ItemTemplate>
<tr>
<td><%#((WebReceiptSummary)Container.DataItem).Type%></td>
<td><%#((WebReceiptSummary)Container.DataItem).PolicyNo%></td>
<td><%#((WebReceiptSummary)Container.DataItem).Date%></td>
<td class="c"><%#((WebReceiptSummary)Container.DataItem).Amount%></td>
<td class="r"><asp:LinkButton ID="pdfLink" OnCommand="PDFLinkClick" runat="server">View PDF</asp:LinkButton></td>
</tr>
</ItemTemplate>
</asp:Repeater>
In your Init or Load in code behind...
receipts.DataSource = GetReceipts();
receipts.DataBind();
Then...
protected void receipts_ItemDataBound(Object sender, RepeaterItemEventArgs e)
{
((LinkButton)e.Item.FindControl("pdfLink")).CommandArgument =
((WebReceiptSummary)e.DataItem).PDF + ((WebReceiptSummary)e.DataItem).PolicyNo;
}
UPDATE
Thinking about it, rather than using the code-behind setting of the CommandArgument, I think (I haven't tested this yet) you could actually do the following without needing the receipts_ItemDataBound function...
<td class="r"><asp:LinkButton ID="pdfLink" OnCommand="PDFLinkClick" runat="server"
CommandArgument="<%#((WebReceiptSummary)Container.DataItem).PDF + ((WebReceiptSummary)Container.DataItem).PolicyNo%>"
>View PDF</asp:LinkButton></td>
UPDATE 2
All instances of Container.DataItem in the above examples, have been changed into the tight-bound ((WebReceiptSummary)Container.DataItem)

Dynamically change the number of header cells in listview LayoutTemplate

I'm trying to dynamically create a listview. on reports.aspx user selects a bunch of checkboxes. On the next page, user sees reports.aspx, and should see a table with columns of the checkboxes he selected. My idea was to create a listview, then dynamically change the header row of the LayoutTemplate, then change the select statement depending on which columns selected. This is what I have:
<asp:ListView runat="server" ID="ReportListView" DataSourceID="ReportListViewSDS">
<LayoutTemplate runat="server">
<table runat="server">
<tr runat="server">
<%
' Doesn't work because code blocks (<%%>) aren's allowed inside <LayoutTemplate> blocks
'For Each i As String In Request.Form
'Response.Write("<th>" & Request.Form(i) & "</th>")
'Next
%>
</tr>
</table>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
</LayoutTemplate>
...
Problem is that this doesn't work because i can't put a code block (<%%>) inside the LayoutTemplate. Is there a way in the code behind to edit the LayoutTemplate, or another way to cycle through the Request.Form vars and build the table header row with it?
Thanks for any advice/direction!
-Russ
Try using the ItemTemplate for the binding syntax instead of the layout template. I believe the layout template is strictly for layout.
Also, it looks like you're using classic ASP code blocks. ASP.NET code blocks look like this:
For data binding:
<%# Eval("<COLUMN NAME>")%>
For other cases not involving data binding:
<%= Request.QueryString["Hello"] %>
Since the control is already a server side control, try giving the and id and then modifying the header on pre-render:
<asp:ListView runat="server" ID="ReportListView" DataSourceID="ReportListViewSDS">
<LayoutTemplate runat="server">
<table runat="server">
<tr id='trCustomHeader" runat="server">
Then in your code behind, attach this logic to the listview's pre-render
ReportListView_PreRender(...)
{
TableRow tr = ReportListView.FindControl("trCustomerHeader");
TableCell tempCell = new TableCell();
tempCell.Text = ...
tr.Cells.Add(tempCell);
}
I just created a separate table on the page, outside of the listview, that was the simple way of doing it.
<asp:Table ID="HeaderTable" runat="server">
<asp:TableHeaderRow ID="HeaderTableHeaderRow" runat="server" />
</asp:Table>
<asp:ListView ...>
...
</asp:ListView>
Then in the code behind:
For Each i As String In Request.Form
If i.IndexOf("checkbox_") = 0 Then
Dim c As New TableHeaderCell()
Dim l As New LinkButton()
l.Text = i.Substring(Len("checkbox_"))
c.Controls.Add(l)
c.CssClass = "customreport"
HeaderTableHeaderRow.Cells.Add(c)
End If
Next
Pretty simple. So I didn't have to use a LayoutTemplate at all.

Paging not working with ListView and Webservice using Linq

I have a simple page that looks up contacts using a webservice with a single method written in Linq. On the page, I have both a gridview and a listview with a DataPager to compare the two. I can get paging working just fine with the gridview, but the Linq code has to return all of the data on each call and let the web page pick out only a page's worth... not the best solution.
I have been told that a ListView will solve this problem, but all the examples I have been able to find have the Linq code on the web page instead of in a separate layer (e.g. a webservice). Ideally, I should be able to tell the web service to bring back a specific page worth of data (starting record number and number of rows), but how do I get the ListView (or the DataPager) to fire an event that asks for this data?
Here is the ASPX code:
<asp:ListView ID="listPersons" runat="server">
<LayoutTemplate>
<table>
<thead>
<tr>
<th>
Site ID
</th>
<th>
PersonID
</th>
<th>
Person Name
</th>
</thead>
<tbody>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</tbody>
</table>
<asp:DataPager ID="Pager1" runat="server" PagedControlID="listPersons" PageSize="5" >
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="true" ShowPreviousPageButton="true"
ShowNextPageButton="false" ShowLastPageButton="false" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ShowFirstPageButton="false" ShowPreviousPageButton="false"
ShowNextPageButton="true" ShowLastPageButton="true" />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("SiteID") %>
</td>
<td>
<%# Eval("PersonID") %>
</td>
<td>
<%# Eval("PersonName") %>
</td>
</tr>
</ItemTemplate>
<EmptyDataTemplate>
No data found...
</EmptyDataTemplate>
</asp:ListView>
Here's the code behind:
private void DoList(string Match)
{
ContactsService cs = new ContactsService();
listPersons.DataSource = cs.Find(Match, 100 );
listPersons.DataBind();
}
and the web serivice:
[WebMethod]
public List<Person>Find(string Match, int Count)
{
if (Count < 5) Count = 5;
using (DataLayer.ContactsDataContext context = new ContactsDataContext())
{
var Persons =
from p in context.Persons
where p.PersonName.Contains(Match)
orderby p.LastName, p.FirstName
select new Person()
{
SiteID = p.SiteID,
PersonID = p.PersonID,
PersonName = p.PersonName,
};
return Persons.Take(Count).ToList();
}
}
Not 100% sure of an answer here. Using the DataPager while binding the DataSource at runtime will add a lot of work but I think it can be done.
Alternatively consider using either a LinqDataSource and wiring up the OnSelecting event or using an ObjectDataSource. Not sure how the DataPager works with an ODS (if at all). The LinqDataSource or the ObjectDataSource will need to be associated with the ListView using the DataSourceID.
If you must bind using the DataSource, you can wire up the OnPagePropertiesChanging event on the ListView along with the PageSize and StartRowIndex properties on the DataPager. You will need to search your control tree for your DataPager since it is likely contained in a template.

Resources