I'm trying to change the testimonials on our site. (Our web developer is out of the picture.) This is what I find in the code for where the testimonials are.
<asp:Repeater runat="server" ID="testimonials">
<ItemTemplate>
<p class="testimonial">"<%# DataBinder.Eval(Container.DataItem, "Text") %>"</p>
</ItemTemplate>
</asp:Repeater>
My research so far has told me there should be a table(?)(dataitem?) somewhere called "Text" with the testimonials listed. It is my understanding that the "asp:Repeater" function repeats a specified format for every item in the list/table. That is all fine. I only need to change the text of the testimonials, which I believe are in this "Text" table or list.
I don't know how to search for this within the website directory. I've downloaded FileZilla, Kompozer, SeaMonkey and Firebug. If any of those programs can help, I will use them, but any way will do.
Basically, I'm looking for a way to search the variety of files and folders within the directory for the table/lists of testimonials. I gave the details at the beginning in case I'm missing something or misguided about the concept.
DataItem is the data source bound to it. Text is a property within the row of the data source. Look for a Repeater.DataSource = X line, or a DataSourceID="X" on the repeater's markup. That will identify the data source.
Related
nesting of image inside a LinkButton shows image on one page & doesn't show image on another page below are two sample code from two different pages in the same root director.It works fine on one page but on the other page is doesn't show any download image rather shows the text download in place of image.
I have done troubleshooting for sometime and replace the code also but it doesnt show download image for any reason on the second page..
<asp:LinkButton ID="lnkbtnDownload" runat="server" onclick="lnkbtnDownload_Click" meta:resourcekey="lnkbtnDownloadResource1">
<asp:Image ID="imgDownload" runat="server" ImageUrl="~/images/download.png" meta:resourcekey="imgDownloadResource1" />
</asp:LinkButton>
<asp:LinkButton ID="lnkbtnDownload" runat="server" onclick="lnkbtnDownload_Click" meta:resourcekey="lnkbtnDownloadResource1">
<asp:Image ID="imgDownload" runat="server" ImageUrl="~/images/download.png" meta:resourcekey="imgDownloadResource1" />
</asp:LinkButton>
HTML OUTPUT
HTML for above two code sample render as below
<img alt="Download" src="images/download.png" id="MainContent_imgDownload">
Download
Both Pages are in the same root directory...
The problem probably comes from a discrepancy in your resource files or missing a resource file completely for the second page. Obviously you have one for the first, but possibly not for the other which has different naming.
If you are using meta:resourcekey, there are some things you have to considerate.
Make sure that your local resource files meet the following criteria:
They are in an App_LocalResources folder.
The base name matches the page name.
For example, if you are working with the page named Default.aspx, the
resource files are named Default.aspx.resx (for the default
resources), Default.aspx.es.resx, Default.aspx.es-mx.resx, and so on.
The resources in the file use the naming convention
resourcekey."property". For example, key name Button1."Text".
Source: MSDN
I'm just starting web-developing now (I do have experience with C#). And I've seen a recommendation to use Web.sitemap to have a list of pages of my website. Does this help? Will I be able to use this instead of having links on my web pages somehow? And what about being accessible to Google so my website will be found by searchers – will this help?
The Web.sitemap is not primarily a control to be used for your main navigation; it's meant as a navigational overview for the user and is typically only needed in large sites. It doesn't affect your SEO in any way - Google is more interested in the quality of your content.
A site map (NOT a Web.sitemap) is a list of pages on your site, and used in conjunction with a robots.txt file, CAN help your SEO. You can use the following tool to generate a site map automatically (although you'll nearly always have to hand tweak it as well):
http://www.xml-sitemaps.com/
The normal way to build navigation for a small/medium site is to create a set of links as an unordered set (ul/li) and style them with CSS.
It is possible to use Web.Sitemap as navigation source, though probably not recommended. I've used Web.sitemap driven navigation for a couple of sites I've developed. However, it really only works well if you have a simple site with static content pages. Here's the code I used for example:
<asp:SiteMapDataSource ID="MainMenuDataSource" runat="server"
ShowStartingNode="false" StartingNodeOffset="0"
StartFromCurrentNode="false" />
<ul id="jsddm" style="padding-top:10px;">
<asp:Repeater ID="MainMenuRepeater" DataSourceID="MainMenuDataSource" runat="server">
<ItemTemplate>
<li><%#Container.DataItem.Title%>
<ul>
<asp:Repeater ID="MainMenuRepeater_2" DataSource='<%# Container.DataItem.ChildNodes %>' runat="server">
<ItemTemplate>
<%#Utilities.GetSecondaryMenuItem(Container.DataItem, False)%>
</ItemTemplate>
</asp:Repeater>
</ul>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
Where Utilities.GetSecondaryMenuItem is just a helper function in our application that uses custom attributes from the sitemap nodes to control the display formatting of the secondary menu.
Links are a fundamental part of any website and there's no reason to avoid them.
A sitemap is just an XML file that defines the site structure, and it's used mainly by search engines to index sites. You can use them for other things too, like crumb trails for example, but they are not a substitute for hyperlinks.
I am trying to create a specific aspx page where I display clickable links based on information in a sql database. For example one column could be the anchor tag another column could be the path to the link itself etc. In the past I would pull this information from sql and put it into a non-visible Label (say linkLabel1). Then in the page itself I would insert <%linkLabel1.text%> to insert the link path from the database to the appropriate area.
I hope I'm not confusing things too much here and that makes sense how I explained it.
What I would like to do is set up a way that I could simply enter a new row into a SQL table with link information and a web page automatically displays the new link for me.
I guess I am mostly looking for insight, opinions, or directions of what approach to consider. I can elaborate if I was unclear (wouldn't be awfully surprising if I was not).
Thanks in advance for anyone's time on this matter.
Since you are displaying this in a table, you could use a GridView for this. The columns that will display the link could be defined as hyperlink columns as so:
<Columns>
<asp:HyperLinkField
HeaderText="Header text"
DataNavigateUrlFields="PropertyContainingTheHRefForTheAnchor"
DataTextField="PropertyContainingTheTextForTheAnchor"
/>
</Columns>
So for example, if you return a record set containing these columns:
TextProperty PathProperty
See Details Assets/SomeOther/
Click me Products/AnotherPath/
Your grid will render these as:
See Details
Click me
If you define the column as:
<Columns>
<asp:HyperLinkField
HeaderText="Header text"
DataNavigateUrlFields="PathProperty"
DataTextField="TextProperty"
/>
</Columns>
Having the following markup
<p>
No items found. Want to
<asp:LinkButton ID="LinkButton1" runat="server" OnCommand="LinkButton1_Command" Text="create" />
a new one?
</p>
how do i localize both the text and LinkButton.Text? I don't want to create two literals that frame the link. Is there a better way?
If you could get away with a straight HTML solution instead of the asp:LinkButton, you could embed the entire thing into one resource string.
No items found. Want to a <href="javascript:__doPostBack('Link1','')">create</a> a new one?
You'd then have to manually check the Request["__EVENTTARGET"] instead of using the wired up event handler.
I'm not saying it's a good idea, but I guess it could work.
In this particular case you pretty much have to. However, your grammar is more complex than it needs to be - you would probably never insert a different word before "a new one" - e.g. "Want to [delete] a new one?" doesn't make sense. So I'd recommend putting "a new one" as part of the link text, so you only need one literal for the "No items found".
I'm coming from a Rails background and doing some work on a ASP.NET project (not ASP MVC). Newbie question: what's the easiest way to make a custom editor for a table of records?
For example: I have a bunch of data rows and want to change the "category" field on each -- maybe a dropdown, maybe a link, maybe the user types it in.
In Rails, I'd iterate over the rows to build a table, and would have a form for each row. The form would have an input box or dropdown, and submit the data to a controller like "/item/edit/15?category=foo" where 15 was the itemID and the new category was "foo".
I'm new to the ASP.NET model and am not sure of the "right" way to do this -- just the simplest way to get back the new data & save it off. Would I make a custom control and append it to each row? Any help appreciated.
You can REALLY cheat nowadays and take a peek at the new Dynamic Data that comes with .NET 3.5 SP1. Scott Guthrie has a blog entry demoing on how quick and easy it'll flow for you here:
http://weblogs.asp.net/scottgu/archive/2007/12/14/new-asp-net-dynamic-data-support.aspx
Without getting THAT cutting edge, I'd use the XSD generator to generate a strongly typed DataSet that coincides with the table in question. This will also generate the TableAdapter you can use to do all your CRUD statements.
From there, bind it to a DataGrid and leverage all the standard templates/events involved with that, such as EditIndex, SelectedIndex, RowEditing, RowUpdated, etc.
I've been doing this since the early 1.0 days of .NET and this kind of functionality has only gotten more and more streamlined with every update of the Framework.
EDIT: I want to give a quick nod to the Matt Berseth blog as well. I've been following a lot of his stuff for a while now and it is great!
There are a few controls that will do this for you, with varying levels of complexity depending on their relative flexibility.
The traditional way to do this would be the DataGrid control, which gives you a table layout. If you want something with more flexibility in appearance, the DataList and ListView controls also have built-in support for editing, inserting or deleting fields as well.
Check out Matt Berseth's blog for some excellent examples of asp.net controls in action.
Thanks for the answers guys. It looks like customizing the DataGrid is the way to go. For any ASP.NET newbies, here's what I'm doing
<asp:DataGrid ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="RuleID" Visible="False" HeaderText="RuleID"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Category">
<ItemTemplate>
<!-- in case we want to display an image -->
<asp:Literal ID="litImage" runat="server">
</asp:Literal>
<asp:DropDownList ID="categoryListDropdown" runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
This creates a datagrid. We can then bind it to a data source (DataTable in my case) and use things like
foreach (DataGridItem item in this.GridView1.Items)
{
DropDownList categoryListDropdown = ((DropDownList)item.FindControl("categoryListDropdown"));
categoryListDropdown.Items.AddRange(listItems.ToArray());
}
to populate the intial dropdown in the data grid. You can also access item.Cells[0].text to get the RuleID in this case.
Notes for myself: The ASP.NET model does everything in the codebehind file. At a high level you can always iterate through GridView1.Items to get each row, and item.findControl("ControlID") to query the value stored at each item, such as after pressing an "Update" button.