I am using an ASP.NET Label control.
<asp:Label ID="LblDescription" runat="server">
LblDescription.Text="Html Tables or/and Texts"
I want to display the content of an editor to this field. My editor can contain text as well as tables.
So if I include labels, how can I display this table to this label? Because table is in HTML format.
I saved the data as nvarchar. So I can retrieve the data from database but I can't access the value in label.text field.
How is this possible? Or is there any other control that meets this requirement?
If you want to insert tables coming from the database, obviously a ´Label´ control is not the proper place due this control is rendered as a span.
You have, for example, the ControlPlaceHolder or the LiteralControl. If it is a regular HTML table, I will choose the second one.
Related
I have tried with field value
<sc:fieldrenderer fieldname="field" runat="server"/>
I am able to get the field value but I need to access the section that contains number of fields
What is the way to achieve that?
Sections are only to get the fields organized so there isn't a control to render all the fields of a section, you have to render field by field.
New to access and I am trying to build a database to organize some in-house parts. I currently have a table containing measurements, photos, etc and having it displayed through a form. The form would show these values and the image of said part. Id like to add two buttons to the form that will
pull up a pdf of the drawing file and
List item processing specs.
So far I have tried creating hyperlinks or embedding the files into the form, but if you were to search for another part, it would direct me to the same two files no matter what part is displayed
I wanted to know if was possible to make it so if you change the search for the data displayed and how to go about implementing it if it is.
I don't know the full circumstances of course, but typically you would add a TextBox control to the form that is bound to the hyperlink field in the table.
If you wish to use a Button instead then I would probably use the Current event of the form (triggered as the user moves between records) to change the hyperlink properties of the button to those of the (bound) hyperlink field. These properties are:
Hyperlink Address, Hyperlink SubAddress and Hyperlink Target
(and the button's Caption)
It might require code on other events as well, to cover different eventualities.
What is the difference between the asp:label and the html label ?
I know that the first one is rendered on the server so basically it returns a span tab, but what is its use? What are the cases in which one would want to use a HTML tag and in what would one want to use the asp:label? I know that if I put it as an ASP control I can programatically access it, but what are differences between the 2 purely in terms of designing the UI?
If the asp:Label has its "AssociatedControlID" attribute value set to the ID of form control on the page then it will actually be rendered as a HTML label control (with the "for" value set to the client ID of the same control) when rendered to the client.
The HTML label control is designed strictly to provide a label/caption for a form control (i.e. an input, select or textarea) which describes the purpose of the form control to the user (see https://developer.mozilla.org/en-US/docs/HTML/Element/label). The label is normally (strongly) associated with the particular input using the "for" attribute which should be the ID of the input. This is particularly useful for those with accessibility needs who are not able to interpret the relationship based solely on proximity of the text and control. Imagine a form with several textboxes but no way to know which input was required in each one. The HTML label control is not used for general text outside of this context.
If the "AssociatedControlID" attribute of the asp:Label has no value then the control will simply be rendered as a span control containing the text. Some developers like to use asp:Labels to output text onto the page, giving the control a dual purpose (unlike the HTML counterpart). I personally prefer to use asp:Literals for this purpose as it gives me more control of the containing markup.
The reason to choose the asp:Label as opposed to the native HTML label control is that you can easily interact with it using server side code, for example changing the text or CssClasses in response to server events, and you can enter the server ID as the "AssociatedControlID" value which will automatically be rendered as the client ID (e.g. shown as "ct100_MainContent_TextBox1" as opposed to "TextBox1") in the "for" value on the client.
On the previous page, the user is going to click a button from a gridview. Each button click will produce a different result on the next page. I want to display text that will put information from a database into the header text. For example, if the user clicks the button next to the "03/04/2012 - 03/11/2012", I want the header on the next page to say: "Please enter data for 03/04/2012 - 03/11/2012".
Is this possible? Is this even recommended or am I better off using an asp:label control?
Yes, this is possible and perfectly acceptable.
Use an embedded code block (sometimes called gator tags) <%=...%> in your markup. The = operator is equivalent to calling Response.Write, so it just outputs the value of whatever you give it inline.
<h2>Please enter data for <%=DateRange%></h2>
In this example, DateRange would be a property on your next page. If you're getting this date range data from a database as you say, then you would need to store it when you click on the grid view button and then retrieve it on the next page.
There is nothing wrong with doing it like this, but storing it in a database seems like overkill just to get the value on the next page. You can use one of the following instead:
Querystring
Session variables
Server.Transfer
A quick google search turned up this page which shows examples of all of these methods.
Regardless of which method you use, gator tags can still be used to set the value of the H2 on the next page.
Also, if you are using Asp.Net 4, then you can use <%: %>. It's Like <%= %> But it HtmlEncodes the output automatically.
Very simple scenario: I have a Repeater with a table spanning its Header, Item, and Footer Templates. Because it spans templates, I cannot simply do <table id="Blah" runat="server"> and then access it via FindControl.
Is there any way to overcome this?
EDIT: The goal is to be able to retrieve the HtmlTable then pass it into another method which parses over it, converting it to excel xml.
In short, no. By turning it into a server control (with runat=server) you can't make it span templates. Why do you need to get to the table element?
I was approaching the problem incorrectly. I should have been trying to pass the Repeater, not the HtmlTable. After changing methods, I was able to accomplish my goal and can now export the Repeater contents as XML.