asp.net, how do you separate a repeater using page break - asp.net

I'm trying to create a batch of letters using a repeater but so far when I convert the letters to PDF the contents of the letters are written one after the other on the same page. I want to split the repeater up so that each letter has its own page. How do I do this?
Please help me!! :)

usually when you convert to PDF, page breaks are controlled with standard CSS styles like page-break-before:always and page-break-after:always applied to any HTML object. These styles can be used either in a CSS class to be applied to an element or inline in the element style attribute.
so in your repeater you should do something like this (pardon my pseudo code):
<asp:repeater>
<ItemElement>
<div style="page-break-after:always;">
<asp:Label id="lblLetter">
</div>
</Item>
</asp:repeater>
where lblLetter is set to your letter in server-side event.

Related

How can I hide <div> in an HTML page in ASP.NET?

I have one div as the following:
<div>
<% # IIF(DataBinder.Eval (Container.DataItem,"Specifiction2").ToString()<> "","")
<div>
I want to hide the above div when "spcefication2" is blank on a .aspx page.
How can I do it?
A couple of things.
You are using IIF, but IIF should never be used. Always use IF instead. The only reason to use IIF is you are stuck with a pre-2008 compiler, and even then, you should use something else.
The easiest way to do what you are describing is via an id and runat="server", you can then either set the visible property (which will mean that the div never gets emitted) or set the style to display:none
If you want to do it inline, per your example, the code is
<div style="display:
<%# IF(string.isnullorwhitespace(DataBinder.Eval(Container.DataItem,"Specifiction2").ToString), "none", "block") %>">
</div>
You are using Eval and container.dataitem, you should look into using ItemType For your grid/repeats, then referencing the value as item.Specification
The above would be much easier if you declared a function in your code behind, taking a string and returning the string none/block.

How to have asp:Localize text have italic text?

I have this:
<asp:localize id="locPopupInfo" runat="server" meta:resourcekey="locPopupInfoRc1"
text="Select up to 8 cameras to include." enableviewstate="false"></asp:localize>
I want to make the text be italic.
I tried adding style="font-style:italic" and style="font:italic". I also tried adding a css:
.italic-text{
font-style:italic;
}
Then doing cssclass="italic-text" and class="italic-text".
None of these worked. Is there any way to do this with asp:Localize?
Localize control inherits from Literal control. It does not output any markup itself, just the content in localized manner. Here is what MSDN says about it:
Although the Label control allows you to apply a style to the displayed text, the Localize control does not.
If you want to apply the style nevertheless, here are the options:
Switch to Label or similar control
Wrap in some server-side control, say Panel, and apply styling to it
Or wrap Localize in a client side tag with style applied. If you are very specific about italic style, you can just do <i><asp:Localize ...></i>
Put your localize into a span and then apply style class onto the span
<span class="italic-text">
Your localze stuff ....
</span>
To understand localize see this

Display the same title text for all elements of the same class?

Lets say I want to display tool tips for links using the title attribute:
<a class="editcommand" title="Edit" ...>
Is there a way to specify the title text for all elements of the same class using CSS, so I don't have to repeat it within each element?
CSS is only for the content of the style="" attribute, not other HTML tags. This sounds like a job for Javascript. If you're using jQuery here's an example:
$('a').attr('title', 'My universal title');
Unfortunately, no, CSS does not provide that ability. Since title is an HTML attribute (besides the <title> element of course), it's up to the markup structure (DOM) to define it, not the style (CSS).
With JavaScript it's just a matter of attaching the attribute to a set of DOM elements with that class. But again, that's modifying the DOM elements themselves, not their style properties.

Richfaces component id in form - css

I have a component inside a form:
<a:form id="myform">
<a:somecomponent id="comp">
</a:form>
and a huge css file, which attaches some style to the component with id "comp".
However, this does not work, as in the rendered html page, the components name becomes "myform:comp".
How can I prevent this? Using myform:comp in css does not seem to work :-(
You have to add prependId="false" to form tag.
<a:form id="myform" prependId="false">
<a:somecomponent id="comp">
</a:form>
You just need to use the richfaces functions detailed here. #{rich:clientId(‘comp’)} can be used in this case.
Edit: also see this answer
The best solution I found up till now is not to use the id, but the style class, and replace all of the occurences of #comp in the css file with .comp:
<a:form id="myform">
<a:somecomponent styleClass="comp">
</a:form>
However, I don't consider this as a 'clean' solution...

Making Text box not editable

work on C# asp.net vs 05. I have a requirment, I have to fill text box with some data on gridview , which is coming from database and make it read-only
After that user can not enter any text on gridview template field. If I set textbox Enabled=false, then i lose text color, but i want to show text color. Just textbox to not be editable. I just want users to not be able to write anything in my textbox.
Isn't there a readonly property for the text box.
If then you can use
ReadOnly="true"
for the text box.
If you can use a label then I would prefer that one.
For wrapping contents inside a label you can use
word-wrap
word-wrap: break-word
Inside the properties choose your column field and in the properties.
Under Styles section
You can give a CssClass to the column.
If you specify CssClass as 'TextStyle'
the css looks like this
.TextStyle
{
color: #a9a9a9
}
In the color attribute give either the color name like 'red' or the hexcode like '#000000' for the text.
Enabled="false"
I'd use CSS to make a label look like a textbox.
Why does everyone insist on using an asp:label for this sort of thing? Just because it renders a <span> if you don't supply an AssociatedControlId?
You should look at using an asp:Panel or possibly an asp:Literal or asp:PlaceHolder for this as they will give you greater control over the output, and cleaner markup.
Panel would be better, as this will render the contents in a <div> rather than the PlaceHolder or Literal which won't add any extra markup.
The content you are putting in here is a semantic division, and so should really be marked up as such, and by default, <div>s are treated as a block display type, rather than as inline (<span>).
Here's a quick proof of concept I just knocked up.
<head runat="server">
<style>
.readTest
{
border: none;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server" Text="Do something" ReadOnly="true"
ID="txtOne" CssClass="readTest"></asp:TextBox>
</div>
</form>
</body>
</html>
Personally I would use a label, though you could write a custom control that renders a textbox or a label, depending on the state your app is in.
I'd prefer to write the text directly to the cell using a literal or String() output rather than using a control. It's a bit cleaner and will help minimize the amount of ViewState being written. Either that, or turn off ViewState for those controls being added.
Specify your CSS for the TextBox in the row created event of the GridView.

Resources