Showing posts with label div. Show all posts
Showing posts with label div. Show all posts

Wednesday, March 28, 2012

AJAX Update div?

Pardon the potential noob-ishness of this question, but I can't seem to put two and two together on this one from the included documentation or the tutorials on Microsoft's website...

What I want is when a user clicks a link (or the equivalent Javascript function is run, since some of my links will be in Flash movies) for the part of the page that contains the text (the non-UI element, basically) to load new text according to what link they pressed. Ideally, I want to load that text from an XML file. I can get a model of this working if I write the AJAX by hand (via the AJAX for Dummies book), but I can't figure out how to use Microsoft's VS AJAX extensions to do this for me. I admit that the streamlined appearance of having the extension do the work from a code point of view is very appealing, and I tend to work better with objects that I can click on and change properties and whatnot than writing everything through code.

Can anyone help me with this? Thanks!!

Right, so I gotta bump this back up because I can't figure this one out...

I've tried making sense ofthis andthis but I can't seem to get either of them working. What I understand thus far about my issue, though, it that I'll need to use Javascript as a bridge between my Flash movie and my ASP.NET page.

Again, the end result I want is this: A user clicks on a button INSIDE the flash movie. Once clicked, that button calls a Javascript function defined in the page the SWF is loaded on (using getURL in Actionscript). That Javascript then passes the data it received from the Flash movie to a div located in an UpdatePanel and triggers an asynchronous postback. The data I'm passing is a string, which is part of a file location for the XML file and stylesheet to be loaded into the div. You can visually see my arrangement atwww.neezer.org/Clean; pressing the buttons in the flash movie currently does nothing (because of this roadblock!), and the text below is the content inside my UpdatePanel that I want to update.

That's my understanding of how something like this would work, though I recognize it may be a little rough and uninformed (believe me, I've spent hours trying to wrap my head around this and haven't come up with anything, which is upsetting). I had dug around and made a custom AJAX implementation of this, using a tutorial I found online somewhere, but I can't use any ASP.NET controls that way, and I want to use an UpdatePanel since it is very well documented and easier for me to customize than writing all the AJAX by hand.

Please, please, please help me!!


Try this out and see if this answers your question:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { // get the XML file location out of the hidden field ServerLabel.Text = string.Format("Here's text we presumably got from the XML file '{0}'.", HiddenXmlFile.Value); } }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager runat="server" /> <asp:UpdatePanel ID="up1" runat="server"> <ContentTemplate> <asp:Label ID="ServerLabel" runat="server" /> </ContentTemplate> </asp:UpdatePanel> <asp:HiddenField ID="HiddenXmlFile" runat="server" /> XML file: <input id="xmlfile" type="text" /> <input type="button" value="Update" onclick="button_click()" /> </form></body><script type="text/javascript"> function button_click() { $get('<%= HiddenXmlFile.ClientID%>').value = $get('xmlfile').value; // in reality, this would come from your Flash movie, not from a textbox on the page __doPostBack('<%= up1.ClientID%>', ''); // force the UpdatePanel to refresh from JavaScript }</script></html>

So yes, after I modified the javascript and C# code a little...

function fetchData(flashVar) {
$get('<%= HiddenXmlFile.ClientID %>').value = flashVar;
__doPostBack('<%= UpdatePanel1.ClientID %>','');
}

if (IsPostBack)
{
string flashVar = HiddenXmlFile.Value;
Xml1.DocumentSource ="~/xmlStaticData_"+flashVar+".xml";
}


... it works just fine! Thank ye kindly, good sir! Now I can sleep!Cool

Monday, March 26, 2012

AJAX Toolkit Modal Popup Extender - Display Issue

I have a site that is using a master page. Within the master page is a div that has a style sheet entry setting the position to absolute. The content div is within this div. My problem is that when the modal popup is displayed and the user has the screen resolution is set to 800X600 the bottom of the modal popup is off of the screen and as the user scrolls down the page the modal dialog moves along with the scrolling keeping the bottom of the dialog off of the page. I tried setting the X/Y parameters for this but as the user scrolls the dialog box still moves, keeping part of it off of the viewable area of the screen. I remove the position absolute setting in the style sheet for the parent div and this issue does not occur, but, my screen is not displayed correctly. This is using IE6. Any ideas?

Thank You for any help.

Actually I was incorrect. It was not the position=absolute causing the error. It was the top=167px that is causing the error. Top is not applied if the position is not specified. That is the root cause of the issue. Please reply if you have a solution.