How to control <li> list item visibility using Eval [closed] - asp.net

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
In an unordered list the visibility of individual list items can be set thus:
<li runat="server" visible=false>Apples</li>
or:
<li runat="server" visible="false">Bananas</li>
But why can't this be done using the 'Eval'method? None of these work:
<li runat="server" visible='<%# Eval("Show")%>'>Carrots</li>
--where Show is a bit that has values of 0 or 1.
<li runat="server" visible='<%# Convert.ToBoolean(Eval("Show"))%>'>Dill</li>
--where Show is a string that has values "true" or "false", or an integer that is either 0 or 1.
What is the answer?

Try
<li runat="server" Visible='<%# Eval("Show").ToString() == "1" %>' ID="bananaItem">Bananas</li>
If that doesn't work, you could also use codebehind if it has runat="server" and an ID:
With CSS (available at client-side):
// make it invisible
bananaItem.Attributes.CssStyle.Add("display", "none");
// make it visible:
bananaItem.Attributes.CssStyle.Remove("display");
Visible-property (not available at client-side, isn't rendered at all):
bananaItem.Visible = false;

Related

how to apply url validator in asp textbox feild [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am new to asp.net & my client needs to fill the url in text box & without proper url the form should not be submitted. Can anybody know how to apply url validator in textbox fields in asp.net.
Please let me know about it thanks
Create a textbox:
<asp:TextBox ID="TxtUrl" runat="server"></asp:TextBox>
Use a regular expression:
<asp:RegularExpressionValidator ID="RegExUrl" runat="server" ErrorMessage="Must be in a website format" ControlToValidate="TxtUrl" ValidationExpression="(http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" Display="Dynamic"></asp:RegularExpressionValidator>
If the field is required before submission, use this:
<asp:RequiredFieldValidator runat="server" ID="ReqUrl" ControlToValidate="TxtUrl" ErrorMessage="Required" />
Alternatively, you can use an HTML5 input with the type of url (w3schools):
<input type="url">

Trying to fire onclick event asp:ImageButton [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
My asp:ImageButton doest not fire onclick event on IE, but is working normally on chrome or firefox.
Don't know if my code is right, but is here:
<asp:ImageButton ID="SaveBtn" runat="server" OnClick="Save_Click"
ToolTip="Save" ImageUrl="images/save.png" />
Using .NET Framework 3.5
Note: IE10
Just install .NET Framework 4.5
IE10 has a bug.
IE10 incorrectly convert coordinates to decimal rather than integer. This causes ImageButton clicks to fail.
You could try some workaround, like:
- change the ImageButton to a LinkButton and put the button image inside of it.
Your code will look like this:
<asp:LinkButton ID="SaveBtn" runat="server" OnClick="Save_Click">
<asp:Image ID="Image1" runat="server" ImageUrl="images/save.png" ToolTip="Save" />
</asp:LinkButton>
Take a look here too.

can we more than one id/class to text box, [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Can i give more than one id/class in below asp text box
<asp:TextBox ID="test" runat="server" CssClass="textbox" Style="width: 125px;"
MaxLength="12">
</asp:TextBox>
You can give more than one css class CssClass="textbox editable wide", but id no. Id should be unique.

asp.net page cant be found [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
asp.net using the hyperlink
<asp:HyperLink ID="HyperLink4" NavigateUrl="~/Diary_Documents/Details.aspx" runat="server" Text="Images"></asp:HyperLink>
to bring the user to the details page inside the Diary_Documents folder.
Iv copied the entire Diary_Documents folder to include list, insert, edit and details both aspx and cs.
Pasted it into the customPages folder renamed it 'Diary_Documents2' then changed the hyperlink to
<asp:HyperLink ID="HyperLink4" NavigateUrl="~/Diary_Documents2/Details.aspx" runat="server" Text="Images"></asp:HyperLink>
but the page cant be found...what am i doing wrong?
Looking at the directory structure, unless I'm very much mistaken, the link should either be-
<asp:HyperLink NavigateUrl="~/DynamicData/CustomPages/Diary_Documents/Details.aspx" runat="server" Text="Images"></asp:HyperLink>
or
<asp:HyperLink NavigateUrl="~/DynamicData/CustomPages/Diary_Documents2/Details.aspx" runat="server" Text="Images"></asp:HyperLink>
The tilda (~) makes it a relative path from the root of the application. Therefore you need to add "DynamicData/CustomPages" to complete the path.
As you don't give the location of the page the link is contained in, I can't show you what the purely HTML relative link would be, but if the page were in "CustomPages" as an example, it would be this-
<asp:HyperLink NavigateUrl="Diary_Documents/Details.aspx" runat="server" Text="Images"></asp:HyperLink>

whats the best way to use tags in aspx [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'd lke to know the best way to use tags in html, using asp tags or using normal html tags.
this:
<asp:Button ID="save" runat="server" Text="Save" />
or this:
<input type="button" id="save" runat="server" value="Save" />
Advantages and Disadvantages
I will use asp tags ,especially in case of buttons i will prefer to use asp tags, Because when you use a html tag for button with runat="server" the attributes like PostBackUrl will not work.
They're just the same. The other one is the so-called server tag or ASP tag and the other one is HTML tag. It's just a matter of style and preference.
Now, if you want to know what is the preferred tags used by ASP.Net developers, I'm sure most of us would agree that it's ASP tags. Well, at least for the ASP.Net Webform developers...

Resources