DataPager with <a> on current page number instead of Label - asp.net

I have a DataPager working fine except for one thing: the current page number is rendered with a Label and I need it to be as innertext for an <a> tag.
Is there a way to do this?

One way would be to subclass DataPager and override Render.
EDIT: Better yet, use a WebControlAdapter.
Customizes rendering for the Web control to which the control adapter
is attached, to modify the default markup or behavior for specific
browsers.
EDIT: Also please see ASP.NET: Can I somehow change the HTML rendered by NumericPagerField?.

Related

Why are some attributes not found in intellisense?

I can't see certain HTML attributes such as tabindex or onblur for standard divs in intellisense - and when writing them at design time they're underlined. However - they work fine when debugging.
Why is this?
There are usually two possible reasons why intellisense doesn't pick them up:
The attributes were not mapped to properties in the control
The control is suppressing the attributes/properties
However, even though intellisense doesn't pick the attributes up, they still get added to the Attributes collection of the control and rendered to the page. It works because they're common attributes for all HTML elements, which is what the controls resolve to when rendered to the page.

making control in user control visible=false on mouse over

More
I have this datalist in a user control i want when i keep mouse over "More", it should be invisible. it is working on .aspx page not on user control. How to do this. This control is placed on master page.
Please Help.
Probably it will be an issue with getElementById. In a naming container you cannot get the element by simply giving its id. You have to use ClientID to get the generated id of the element at runtime.
Something like
document.getElementById ( "<%= DataList2.ClientID %>");
See Control.ClientID Property
and
Control ID Naming in Content Pages
I would agree that it's probably an issue with trying to get the id of the element since the element's id changes at runtime when you put it inside a user control. You can run your code then do a view source in the browser and see exactly what the id is generating to at runtime.
Have you tried debugging the javascript mover() and mout() function? I am guessing you are looking for elements with the wrong id's since the id's are probably different inside a user control.

UpdatePanel in repeater overwrites controls underneath it

I have a Repeater with an ASP.NET AJAX 1.0 UpdatePanel inside it. There are buttons outside of the UpdatePanel but still in the repeater. When a section inside the UpdatePanel appears (it's a hidden Panel control that appears when user answers a question a certain way), the buttons at the bottom disappear.
Here is an illustration.
[REPEATER]
[UPDATEPANEL]
[QUESTION] <-- when user says yes, Panel appears
[PANEL]
[/UPDATEPANEL]
[TABLE] <-- This table is no longer visible.
[Button]
[/TABLE]
[/REPEATER]
If I move the table to the top of the page, the content does not disappear, so I suspect it is a style issue, where the controls are actually there, but are underneath the content of the UpdatePanel. I've tried adding a <br clear="all"/> to just before the table, to no avail.
Any idea how I might fix this?
Edit: I had an errant missing closing tag that caused the UpdatePanel to extend further than it should've, so it was hiding my control. Using the Firefox plugins helped identify this.
My suggestion is to use Firefox and the Web Developer toolbar to do a View Generated Source after the update has occurred or inspect the elements with Firebug. If the table html is still on the page, then it could be either a style issue or an issue with malformed HTML in the panel causing the table not to render properly. If the table html is missing, then it is being removed from the DOM (or overwritten) by the AJAX callback. You might be able to use Firebug to debug the actual AJAX callback as well to see what and when things are actually being replaced.
Posting the generated HTML before and after the update in your question would also be helpful if you still can't figure things out and want more input.
Put the table inside the updatepanel, or put the whole repeater in one updatepanel.
Note that the Clear attribute is Deprecated as of HTML 4.01, and isn't included in XHTML Strict - what document type are you using - if you're using strict (and you're clearly using XHTML of some kind, because you've closed your br), then your browser has every right to ignore the clear attribute.
You would be better off doing this with CSS:
<style type="text/css">
.cleaner{
clear: both;
}
</style>
<br class="cleaner" />
Also, you could try putting the br after the panel, so that it comes back in the UpdatePanel and forces the browser to honour it.

ASCX controls ASP.NET - Cannot find Visible method

In a particular page i have a ascx control which contains a table.
Now I want to set this control visible/invisible but the visible method is not detected by the intellisense.
The only methods are 1)Equals and 2) ReferenceEquals
Main Page
<VPM:VotingPolls Runat="server"></VPM:VotingPolls>
Thanks
Thanks it has been solved
The problem was that no id was set.
<VPM:VotingPolls ID="VPS" Runat="server"></VPM:VotingPolls>
then
VPS.Visible=True/False
Make sure that your markup is well formed and that there is a proper header line for the ascx control on your page. 99% of the time, if intellisense doesn't work, it means that something is wrong with the code and/or markup.
Sometimes intellisense doesn't display available attributes. But the visible attribute will be available. So just type visible='true/false'. That should work.

Cleaning up .NET HTML generation

I am looking to clean up some of the HTML generated by a .NET 2.0 TreeView controller. Switching to another version/model is not an available option.
My first crack yielded an extended TreeView, with an overridden Render that Regex'd out the text I didn't need and output to the page.
The problem was when I tried to collapse/expanded nodes of the tree, my postback event wasn't fired. My assumption was that I didn't need to do any more overriding as the parent TreeView controller would handle the postback events.
What am I missing?
Use the ASP.NET CSS Control Adapters:
http://www.asp.net/CSSAdapters/TreeView.aspx
Without adapters both use HTML <table> tags. Control adapters can be used so that nested <ul> tags are rendered instead. A combination of CSS and JavaScript can then be used to show and hide portions of the hierarchy of the tree or menu.
When the CSS and JavaScript are removed the adapted HTML degrades into simple nested unordered lists that are easily interpreted by screen readers, etc. You can see this for yourself by setting the theme to None in the Theme Chooser on the left.
You regex'd out something that the control needs to handle postbacks. It may be the highly-convoluted id's or the runat attribute... whatever it is, if you're stuck with web controls, you're stuck with bad html.
Your only true (and non-destructive) way to do what you want is not by extending current controls, but by using Control Adapters. There are already control adapters that use css for positioning. Here's ScottGu's post on these CSS adapters.

Resources