Practical use of AJAX Accordion control - ajax

The Ajax accordion on my page isn't functioning at all. It displays fine on the page, but I can't seem to expand/collapse the panes when I click on their Headers.
Here's my code (just the HTML portion as I'm not aware of any code behind that is needed):
<aj:Accordion runat="server" ID="acMain" SelectedIndex="0"
FadeTransitions="true"
TransitionDuration="400"
FramesPerSecond="40" RequireOpenedPane="false" TabIndex="0"
SuppressHeaderPostbacks="true" HeaderCssClass="acHeader"
HeaderSelectedCssClass="acHeaderSelected">
<Panes>
<aj:AccordionPane runat="server" ID="Panel1">
<Header>
...
</Header>
<Content>
...
</Content>
</aj:AccordionPane>
<aj:AccordionPane runat="server" ID="Panel2">
<Header>
...
</Header>
<Content>
...
</Content>
</aj:AccordionPane>
</Panes>
</aj:Accordion>
I've checked the official page for the Accordion as well as a number of blogs on the subject (all of which seem to be a copy of the official page with the author's own wording) and according to all of this, I can't see that I've done anything wrong or missed anything out.
Matter of fact, I've checked an Accordion my boss made a while back and my code's basically the same as his (only panel content is different) and he has no code-behind either, so I'm really lost here.
Any help will be greatly appreciated
EDIT
After adapting my code according to a sample on asp.net, I've managed to collapse the first pane (SelectedIndex 0), but the other one won't expand :/

So I copied the accordion code from the asp.net how to page and put my content into the panes, still had no effect.
As it turns out, there was a rogue </div> tag in my content that was wrecking the accordion so I recommend that anyone having any similar problems checks their content very thoroughly.
Also, it's worth noting here that as this particular sample worked for me and because I'm telling you to use it if you're having trouble, it's author did leave an incorrectly closed </p> tag that might cause problems with your accordion during testing, so watch out for that.

Related

Make entire div clickable

I am trying to get the whole div clickable and this works but only with a straight link to another site. Is there a way to make it work with this text in it also:
<div class='reddit' title='Share Us On Reddit' onclick="window.open('http://www.reddit.com/submit?url=httpsFwww.example.com&title=XXX is Cape Breton's Homepage. Start Your Web Search With Beautiful Cape Breton Island')">
Thanks
From CSS Tricks
This probably isn't a thing you need to rely on JavaScript for
anymore. Since HTML5, this is perfectly valid:
<a href="http://example.com">
<div>
anything
</div>
</a>
And remember you can make links display: block; so sometimes you
don't even need the div.
<div style="cursor:pointer" onclick="document.location='evenidontknow-page.html'">
<h2>Full Div Clickable</h2>
</div
The above code helped me very well, and this will not require any extra code.
Using a tag may solve the problem but we need to add extra code to it.
please check this link for more info w3schools
Bootstrap has a feature called "Stretched Link". From the documentation:
Make any HTML element or Bootstrap component clickable by “stretching” a nested link via CSS.
You can read more by visiting the following link:
https://getbootstrap.com/docs/4.4/utilities/stretched-link/

Page update after asyncfileupload completes upload

I see this question asked frequently and I have done extensive experimentation to try to get this to work. However everyone else's examples and answers have so far failed me. I am bemused. Here is the situation:
AsyncFileUpload is NOT in an UpdatePanel
Image and Label to be updated are in an UpdatePanel
Update should occur after the upload completes
The upload is indeed saving the file as expected. My problem is regarding getting the page to update after that happens. The file being uploaded is an image, and I would like that image to update. I am aware of some problems with images not updating on the client if you reuse filenames, but I am also printing it to a label just to be sure. I am certain the UpdatePanel I am targeting is not updating.
I have tried the following approaches:
Using the server side method to manually update a conditional UpdatePanel - this fails because the file upload is done in a frame. Sniffing the returned HTML shows that the correct HTML is actually sent back after the post, but of course to the wrong frame.
Using the client side method to trigger a javascript postback to my UpdatePanel. This does not work and I cannot tell why.
Using the client side method to trigger a javascript button click inside the UpdatePanel. Again, nothing happens and I don't know why.
Setting the UpdatePanel's trigger up so that it points directly at the AsyncFileUpload. No joy, but I knew that would be a long shot, keeping in mind the hidden frame.
Moving the AsyncFileUpload into the UpdatePanel and trying some variety of the above. When I do this, I lose all handle of the file being posted to the server and I cannot save the file in the first place.
Normally when I get this kind of error, where all the tutorials appear to be wrong, it turns out that my error is because I didn't set an ID on a control somewhere and it somehow mattered. I can't even see that in this case. Here is some code.
<fieldset class="pj_Pics">
<ul>
<li>
<label>Picture 1</label>
<asp:UpdatePanel ID="ajax_Pic1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:Image ID="img_Pic1" runat="server" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
<div style="position:relative;">
<div class="photoChooser">
<ajaxToolkit:AsyncFileUpload ID="fu_Pic1" runat="server" CssClass="pj_PicChoose" Width="84px" OnClientUploadComplete="picPost1" OnUploadedComplete="fu_PictureFile_UploadedComplete" ThrobberID="throb1" />
<span><asp:Literal runat="server" Text="click to change"></asp:Literal></span>
<asp:Image ID="throb1" runat="server" ImageUrl="~/images/throbber.gif" AlternateText="uploading image" />
</div>
</div>
</li>
</ul>
</fieldset>
protected void fu_PictureFile_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
bla bla bla;
// and update the image
img.ImageUrl = "~/" + webfolder + imageFileName;
thing.Text = img.ImageUrl;
}
function picPost1(sender, args) {
document.getElementById('<%# Button1.ClientID %>').click();
}
Any help greatly appreciated. There is obviously a ScriptManager on the page and the code I've shown is just the last thing I have attempted. Let me know if there is anything else you need to see.
Thank you!
I happen to face the same situation today, and this is how I solved it.
According to this LINK, there's no Postback is happening or even a ViewState since its Asynchronous FileUpload.
So in OnUploadedComplete I test file type and size before executing the SaveAs() in codebehind, then I test the same in OnClientUploadComplete to display messages and carry on the rest of the work like setting Images URL. Hope this helps.

Make Share icons from Add This align horizontally instead of vertically on self hosted WordPress

I have a problem that has taken me days to figure out.
The social follow icons I get from AddThis website appear vertically instead of horizontally. I want to make it appear horizontally but I have found that it is impossible to do so.
Below is the code I got from https://www.addthis.com/get/follow
<!-- AddThis Follow BEGIN -->
<p>Follow Us</p>
<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_facebook_follow" addthis:userid="TheMostafaAbedi"></a>
<a class="addthis_button_twitter_follow" addthis:userid="theMostafaAbedi"></a>
<a class="addthis_button_google_follow" addthis:userid="106914586115617584077"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/300/addthis_widget.js#pubid=xa-506a607f490b6601"></script>
<!-- AddThis Follow END -->
The specific page that the problem occurs is http://www.under-review.com/about under Mostafa Abedi description.
You've got line breaks between lines of code, which makes the icons go one below the other. You're most likely using the WordPress editor to insert the code, which alters the formatting.
If you're using Visual editor, switch to HTML editor and give it a try.
If you're using HTML editor, at the very least remove all the spacing between items, making them placed in one line, which would prohibit WordPress from entering new lines, i.e.:
<a class="addthis_button_facebook_follow" addthis:userid="TheMostafaAbedi"></a><a class="addthis_button_twitter_follow" addthis:userid="theMostafaAbedi"></a><a class="addthis_button_google_follow" addthis:userid="106914586115617584077"></a>
From my experience, about 90% of all formatting issues are fixed by good code and as a rule I follow W3C. I suggest you validate against that because at the moment it fails (both the HTML and CSS fails)
http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Funder-review.com%2Fabout%2F
http://jigsaw.w3.org/css-validator/validator?profile=css21&warning=0&uri=http%3A%2F%2Funder-review.com%2Fabout%2F

Telerik:RadRotator Not displaying(rendering) in IE9

Ok i have a telerik:RadRotator on my page that loads a few images from the db, the rotator displays correctly in both FireFox and Chrome but when i open it in IE9 the rotator div is placed on the page but the rotator itself doesn't display(render).
<telerik:RadRotator ID="RadRotator1" runat="server" Width="791px" Height="215px"
ItemHeight="215px" ItemWidth="791px" OnItemDataBound="RadRotator1_ItemDataBound"
RotatorType="AutomaticAdvance" FrameDuration="10000" ScrollDuration="3000" CssClass="ImageRotator"
ScrollDirection="Right" PauseOnMouseOver="false">
<ItemTemplate>
<asp:HyperLink ID="hypImage" runat="server">
<asp:Image ID="imgScroller" runat="server" Width="791" Height="215" /></asp:HyperLink>
</ItemTemplate>
Any ideas as to what is happening here? I have tried to remove the styles applied and nothing.
Such problems are often related to an incorrectly formatted HTML that is not ignored by IE, especially older versions of the browser. The only issue that I found in your code was the unclosed RadRotator control tag, although most probably you have missed it by accident. Since the code from your sample appears to be valid, it is possible that an erroneous content is inserted from the data source. Please verify that the content in the datasource is entered correctly and that the data, populating the items of the rotator, is properly escaped before it is used. You can also check if the RadRotator's items are rendered properly by examining the content of the li elements in the HTML representation of the control on the source of your page.
Ok after much fuss I found that the scroller itself was wrapped in a hyperlink. After removing the hyperlink everything works 100%

Link to anchor tag on a different page not working in Firefox

I have a link at the bottom of a page, and its purpose is to link to an anchor on a different page. It doesn't seem to work in Firefox (at least, not in v8). Instead, on load it goes right to the very bottom of the page.
Any help is appreciated!
Source: http://msi.emsix.com/news/1900/1/Six-in-Ten-Employers-Hope-Health-Care-Reform-will-be-Repealed.aspx (the "Susan McIntyre" link at the bottom)
Anchor markup:
<h3 id="mcintyre" name="mcintyre">Susan McIntyre</h3>
Try adding the following code:
<a name="mcintyre"></a>
<h3 id="mcintyre">Susan McIntyre</h3>
This works correctly if I disable javascript.
It looks like what happens is that the scroll is done before you use script to collapse away a bunch of the content. So the final scroll position ends up wrong.
If you're collapsing the content away async, that could do it...
If you are unable to create <a name='%hashName%'></a> anchor, consider this:
$(document).ready(function(){
$(window.location.hash).append('<a name="' + window.location.hash.replace('#','')+ '"></a>');
window.location.href=window.location.href;
});
I know it looks weird, but works fine.
Since today I haven't heard about div anchor tags. Are you sure it is proper to expect such kind of behaviour from browsers?

Resources