PlaceHolder - how to replce placeholder in aspx? - asp.net

I have a PlaceHolder component in my project, but I want to place it in right part of the page, as now it's placed in the top. Is there any opportunity to change it's alighn?
<asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible="true">
<dx:ReportParametersPanel ID="reportParameterPanel1" runat="server" ReportViewerID="ReportViewer1">
</dx:ReportParametersPanel>
</asp:PlaceHolder>

I think you should enclose the entire Place Holder code in a Div and set the Style of the Div to Float:Right.
For more controlled positioning of the Div, use:
Position:Absolute;

Related

Add tool tip to Asp Drop-down list

When I add a tool tip attribute to asp drop-down list, its not showing any tool tip,When I include this drop-down in the div tag and give title attribute for the div tag, then i can see the tool-tip.
<div title="Professions">
<asp:Dropdownlist runat="server" ID="ddlProfession" DataValueField="ProfessionName" DataTextField="ProfessionName" Width="260px">
</asp:Dropdownlist>
</div>
But I don't want to add any extra div or any other container. directly i want the drop-down to show the tool tip.even it is fine, if you can guide me how to add title attribute for input tag of asp drop-down list which comes after rendering.
It should work:-
<asp:Dropdownlist runat="server" ID="ddlProfession" DataValueField="ProfessionName"
DataTextField="ProfessionName" Width="260px" ToolTip="Some Text">
</asp:Dropdownlist>
Please note it will render Html select with title attribute as Some Text. So you don't need any extra div.

Watermark for an ASP.Net Panel

Does an asp.net panel can be inserted with a watermark? These panel is used for printing purposes. Another problem is that the background image in the panel is not printing, only the objects inside of it.
I think you should take a look at BackImageUrl property. And assign the path of the watermark image to it.
<asp:Panel BackImageUrl="yourimagefile.png" />
Also, the image should be given a proper opacity / alpha value so that it's transparent.
Here is one more example http://www.codeproject.com/KB/web-image/ASPImaging1.aspx from codeproject that you can do many thinks on the image, including adding watermark from image.
<asp:Panel ID="Panel1" runat="server">
<asp:Image ID="Image1" runat="server" ImageUrl="~/yourimage.png" />
<div style="margin-top: -xxx"><--change the position <div> to overlaps with the image
....
your content here
....
</div>
</asp:Panel>

Hide the html contorl from the server side without using attributes runat="Server"

I am using HTML control,and want to visible false from the server side with out using attributes runat="Server"
tell me any solution
Runat="Server" has got nothing to do with visibility.
If you want to hide the control (so that its not visible to any visitors to your site) you would simply set its CSS to visibility:hidden; or display: none;. I think this is what you wanted to know.
Wrap your html controls in an asp:placeholder control, and set the visibility on the placeholder.
Example
<asp:placeholder id="plc" runat="server" visible="false">
<h1>Some Content</h1>
<img src="/images/someimage.gif" alt="" />
</asp:placeholder>

ASP.NET: I'm getting strange output when styling a Label control

.labelOne { border-width:thin;
border-style:solid;
border-color:Red;
background-color:Silver; }
<asp:Label ID="Label1" runat="server" CssClass="labelOne">
<h1>Hello world</h1>
</asp:Label>
<br /><br />
<asp:Label ID="Label2" runat="server"
BorderColor="Black"
BorderStyle="Solid"
BorderWidth="1px"
BackColor="Silver">
<h1>Hello world</h1>
</asp:Label>
Hello. In the code sample above I have 2 Label controls with their contents set to an h1 header tag. The first Label is styled using css, and the second with the Label's inline properties (both Labels have identical styling). But the first Label doesn't output properly, it's border is broken. If I replace the first Label's markup with plain "Hello world" text it renders properly, but it breaks again when I use markup. Can someone explain why this is happening?
You're rendering invalid html. Label controls put their contents inside a span or label html tag by default, so now when you put h1 tags inside the label you have a block element inside an inline element, which is invalid.
You should wrap your h1 tags outside the label control, and then perhaps use a literal control instead — like this:
<h1 class="LabelOne"><asp:Literal ID="Label2" runat="server">
Hello world
</asp:Literal></h1>
Note that you could also easily apply inline styles to h1 if you wanted... not that I recommend inline styles, though.
Add this to your CSS:
display:inline-block;
Apparently Asp.Net adds that css style for you when you use the inline styles on a label.
By the way, I was able to spot the difference between the styles applied to the 2 labels (span tags) very quickly by bringing it up in Firebug.
Label is the wrong control to be using here as it renders a html <label>, which defines a label for an input element.
It would make more sense to use a Panel which will render as a <div>.
A span-element (which is what the asp:Label outputs) is an inline element, and can not contain block level elements like h1. This might be the reason why it breaks.

How do I center an image provided as an ASP.NET image control?

The question is pretty straightforward. I have an <asp:Image> which lives in an <asp:Panel>. My goal is to provide a very basic "print preview" where either left, center, or right alignment is selected. The panel represents the full print area (a sheet of 8.5" x 11" paper) and the image inside is the area that will actually get printed. The full code is this:
<asp:Panel ID="Panel2" runat="server"
BackColor="Black"
BorderStyle="Inset"
Width="425px"
Height="550px" >
<asp:Image runat="server" Height="425px" ImageAlign="" />
</asp:Panel>
I set the ImageUrl property in the code behind, no problems there. If I want to align the image all the way to the left or right, I can just specify ImageAlign="[Left|Right]". However, I haven't been able to find a way to center the image in the panel. I've tried all the different ImageAlign values and none of them seem to do what I want. Am I SOL here? If I have to, I can alter the CSS class for the image or panel but I couldn't figure out anything successful with that approach either.
what if you use panel HorizontalAlign="Center" property.......
<asp:Panel runat="server" ID="Panel2" HorizontalAlign="Center">
</asp:Panel>
in your panel tag (which becomes a div client side) just add this attribute:
CssStyle="text-align:center;"
Though that would center EVERYTHING within that panel.
Perhaps just set the CssStyle of the image to a hardcoded left-margin? If your goal is a fixed width print preview, this should be ok.
Panel CSS Property:
CssStyle="alignCenter"
CSS:
.alignCenter
{
margin: 0 auto;
}
you can either use inline style sheet or external style sheet to accomplish this and add your css code in it

Resources