Eval property and extra text on a button's text property - asp.net

I'm using an asp Button like follows:
<asp:Button id="someButton" runat="Server" Text='<%# Eval("Size") %>' />
This is great but before the Eval Property result I wanted to add the Text "Download " with possibly the units after it.
eg. Download 123KB.
Can someone please tell me how to go about this?

In this case it might be easier to set the text property of the button on the server in the page load event.

insted of button use linkButton.
**asp:LinkButton ID="HyperLink2" OnClick="HyperlinkSelectedCustomers_Click" runat="server" CommandArgument='<%#Eval("id") %>' ><%#Eval("selectedCustomers") %>/asp:LinkButton

Related

how to create pop up window with hyperlink in asp

I am trying to create a popup window when clicked the hyperlink. Currently, my hyperlink is opening the entire page which is huge and i would like to make like a pop up, smaller size. How can i do that?
Here is my code:
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("ID", "~/DET/Policy.Merket?ID={0}") %>' Target="_blank">POLICY</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
i come back just to post the solution in case someone needs:
`<asp:Hyperlink Runat="server" NavigateUrl='<%# Eval("ID", "~/DET/Policy.Merket?ID={0}") %>' onclick="window.open (this.href, 'popupwindow', 'width=400,height=400,scrollbars,resizable'); return false;">Link text goes here<asp:Hyperlink>`
You could use the javascript window.open() function in a pure HTML button. Copying from here, you can see an example defining the popup window size etc.
Link text
Another alternative would be to use jQuery and specifically the overlay tool.
Hope I helped!
use the ajaxtoolkit modalpopup
it will much more helpfull for you
thanks,

RequiredFieldValidator Control displays the Error Text on Page_Load

I am having trouble with the <asp:RequiredFieldValidator> in this code.
<asp:Label ID="email_Label" runat="server" Text="Email"></asp:Label>
<asp:TextBox ID="email_Text" runat="server" MaxLength="40" Width="250"></asp:TextBox> *
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="email_Text" Text="Required"></asp:RequiredFieldValidator>
According to the W3schools documentation here I have used the <asp:RequiredFieldValidator> correctly, however instead of displaying the label and text box the page also displays the error message. This happens on page_load so the value has not had a chance to change from the default yet. I want the error text to display after the user clicks the Save button at the bottom of the form I am building.
What is Being Displayed:
Email[TextBox] * Required
What Should Be displayed:
Email[TextBox] *
Am I missing a parent element for the validator or something. According to the example on w3schools site no parent element should be needed. In fact the way they have their example set-up is exactly what I was expecting for this.
Use Validation Group if want to display Error message on Button click. Like this.
<asp:RequiredFieldValidator ID="rqtxtQName" ValidationGroup="save" ControlToValidate="txtQueueName" runat="server" ErrorMessage="Some required field are missing." SetFocusOnError="True"Display="Dynamic"></asp:RequiredFieldValidator>
and use validation group on Button also.
<asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="save" OnClick="btnSubmit_Click"/>
Hope it will helps.
you should use ErrorMessage instead of Text
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="email_Text" ErrorMessage="Required"></asp:RequiredFieldValidator>
If you want to validation on save button click event then set property ValidationGroup="Group1"
for RequiredFieldValidator and also for save button. So it will check validation when you click save button.
And For display message you can use ErrorMessage property.
Thanks,
Hitesh
Set the RequiredFieldValidator this way. Remove the property: 'TextRequired' & put a * inbetween the opening and closing tag.
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="email_Text">*</asp:RequiredFieldValidator>
Also, Do not set the ErrorMessage property as this will again not fit your requirements.

Add a linkbutton (hyperlink) to Text attribute of a Control in ASP.net

I am working on ASP.net page and is there a way I could add a linkbutton to Text attriubte of another control, say a checkbox. So something like this,
<asp:CheckBox ID="chkAccept" ForeColor="Red" Text="Check this box if you can see <linkbutton onclick-"dosomething()> this popup</linkbutton></asp:CheckBox>
Here, user will see the text in checkbox but, "this popup" will be a linkbutton to open a popup.
Thanks for any help in advance.
You can't have a control inside the attribute of another control. What I would do is take the text out of the control and have it appear as separate markup after the control. Then you can do whatever you want.
<asp:CheckBox ID="chkAccept" ForeColor="Red" />
<span>Check this box if you can see <asp:LinkButton OnClientClick="dosomething()" Text="this popup" />.</span>

ASP.Net Label control's Text property not updating text under button click event

I have developed a small application in SharePoint. I am using custom application page and load .ascx Control over that page under Page_Load() method. In .ascx Control, I have created a small form with text boxes and a button Control. under this button click event, I want to change the text property of label like: lblConfirmation.Text = "Confirmation is OK"; but it did not change the text. It shows nothing because i set text property empty in label Control.
<asp:Label ID="lblConfirmation" runat="server" Text="" ></asp:Label>
Any Idea, what is wrong ?
What are this single quotes in your asp:Label definition ? please check this
<'asp:Label ID="lblConfirmation" runat="server" Text="" ><'/asp:Label>
it must be replaced by
<asp:Label ID="lblConfirmation" runat="server" Text="" ></asp:Label>
Try to debug the code in your visual studio and let us know if you get any error ?
Thanks

Postback using button in GridView

I have the following in an ASP.NET GridView:
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ibtnDown" runat="server" ToolTip="Down" CommandName="Down"
ImageUrl="~/images/arrow.png" Width="16px" Height="16px"
CommandArgument="<%# Container.DataItemIndex %>" />
</ItemTemplate>
</asp:TemplateField>
It's simply an image button that when clicked raises the RowCommand event for the GridView. It is very convenient in that it allows me to use the CommandName and CommandArgument in order to determine the button that was clicked and for which row it was clicked.
However, I find that the .NET ImageButton is limited in that it can't display CSS sprites in order to change the image on mouseover. At least I couldn't get it to work, but of course that doesn't preclude some manner in which it's possible.
Anyway, I'd like to use a standard HTML button tag because I know how to get it to work with my sprites.
<button name="btnDown" id="btnDown" type="submit" class="downArrow"></button>
But what I don't know how to do is get the button to cause a postback and raise the RowCommand event and still allow me to somehow access the CommandArgument and CommandName parameters.
Right I would make the button a server control first, then use its various properties as an alternative to commandName and CommandArgument. Additionally I would use OnServerClick event in place of rowCommand. I would use at last the sender object parse it to an hmt button and extract the values out of its properties. I think I'vent got lost.
<button runat="server" name="Down" id="btnDown" title="<%# Container.DataItemIndex %>" type="submit" class="downArrow" OnServerClick="ClickMe"></button
Have you considered using a button field to perform the action you wish to do?
Take a look at the following link
ButtonFields within a GridView
Just use (original post here):
<asp:LinkButton ID="LinkButton1" runat="server">
<div class="sprite-box_mac_osx_disc_button" />
</asp:LinkButton>
Of course use your own css with all width, height, background and background-position. And add Command and CommandArgument to LinkButton.

Resources