Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Wednesday, March 28, 2012

postback inside modalpopupextender

I want to show a modalpopupextender that contains: a textbox ,A button, gridview, ok button , close button: when the user click on A button the gridview must be populated , I need this behavior inside the modalpopupextender but it seems like modalpopupextender does not support any control that make a postback, How can I manage this??

Best Regards

Joseph

I already have done this what you need to do is,

let say. btnSearch popups your ModalpopupExtender,

when you click in side the control do one thing only in the code behind, of that click event either grid pageindexchange, sortiung, any button click in the last. that is.

ModalPopupExtender1.Show()

it will keep showing the popup until you click close button or call a method.

ModalPopupExtender1.Hide()

It is trial and tested, even I have done more than this in my application.

IF THIS MAKES ANSWER PLEASE CLICK ANSWER ON MY POSTING

Regards,


Hi Killerjocker,

My understanding of your issue is that you want to show some controls include the GridView and generate(update) the content inside it when click on the Button which is associated with the ModalPopupExtender. If I have misunderstood, please feel free to let me know.

In my opnion, I think the easiest way for your situation is adding a UpdatePanel into the Panel which is associated with the ModalPopupExtender and the GridView is put inside the added UpdatePanel. When user click on the Button, the UpdatePanel will be refreshed by sending a asynchronous post and then the shows the ModalPopupExtender. Here is a sample:

<%@. 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"
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style>
.modalBackground {
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}

.modalPopup {
background-color:#FFD9D5;
border-width:3px;
border-style:solid;
border-color:Gray;
padding:3px;
width:250px;
}
</style>

</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Button ID="Button2" runat="server" Text="Button" Enabled="false" style="display:none"/>
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Height="50px" Width="235px" style="display:none" DefaultButton="Button4">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<%=DateTime.Now.ToString()%>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" Text="Cancel" />
<asp:Button ID="Button4" runat="server" Text="Button" />
</asp:Panel>

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button2" PopupControlID="Panel1" CancelControlID="Button1" DropShadow="true" BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<input id="Button3" type="button" value="Click Me" onclick="showModalPopup()"/>
<script type="text/javascript" language="javascript">
function showModalPopup(){
__doPostBack('<%=UpdatePanel1.UniqueID%>','');
$find("<%= this.ModalPopupExtender1.ClientID%>").show();
}
</script>
</form>
</body>
</html>

I hope this help.

Best regards,

Jonathan

Postback to Open Window

i have a button in an update panel that checks through some business logic and if errors/warnings are generated i need to report them to the user.

i have no room on the screen to use for this and would like to show a dialog/window with anything to report.

anyone any ideas on how i could achieve this?

cheers

you can try to build a message control that has absolute position (CSS) , and it located in the center of the page (on top of every elements of page (using z-index)) with ok and close button.

the message control will be placed in every page and have it hidden before any message send, maybe you want to put it in master or basepage if there are a lot of pages going to use the control.


Use javascript:window.alert('Your message here!');


If you're using the AJAX Toolkit, check out theModalPopup Extender.

If you're not, jQuery'sBlockUI plugin is a nice way to accomplish that as well.


thanks for all the feedback.

i eventually used the modalpopup to handle this and works perfectly.

thanks again all...

PostBack with query string...

hi,

Here is what I am trying to do, I have a user control, usercontrol is one of many being loaded in a single default.aspx, inside this user control, there are Atlas TabPanels, in several tab panels there are user controls, in these user controls, there are controls causing a postback, the problem is when page is reloaded, it returns to default tabs, I like to pass a query string that contains active tab, but how can I do this in javascript? I am not sure where to put this here or in Atlas forum. Thanks in advanced.

Hi,

I think u need to set the smartnavigation propery to true . so that focus will not be lost during the postback

Swati


Hi,

Because there is a full postback, you need to use a HiddenField to maintain the current active tab index.
After the postback completes, active the corresponding index with javascript.
Like this:
$find('<%=TabContainer1.ClientID%>').set_activeTabIndex(the value kept in the hiddenfield);

Hope this helps.

Monday, March 26, 2012

Probably a stupid question........Flash>Atlas ?

This is probably a dumb question but....anyway.....
Hasn't this kind of 'client side processing to provide a richer user experience without postbacks' already been implemented a billion times better by Macromedia Flash ? What are the benefits of atlas over flash ( please don't say 'you need a plug-in for flash' as the flash player is pretty much ubiquitous now )?
Or is it just utterly stupid to try and compare them both?
How is Atlas related to AJAX?

There are no dumb questions.Smile [:)]
Here are my answers as oppossed to anyone else's:
Atlas is Microsoft's implementation of Ajax for the .NET platform.
I see Flash and Atlas as different products. Flash started as graphical animation over the web. It is trying to grow to provide a programmable interface, however, the languages semantics of Flash are problematic according to a developer friend of mine. His company tried to create a complete web ui using flash and they gave up based on a number of technical issues, including the fact that there was little documentation regarding how to create an application, limited support for most programming items (try-catch being one), and a few other things that escape my mind at this moment. I believe that there is a Flash Server that provides a lot of this functionality, but I don't know anything about it. I don't remember all of the issues that he brought up, but there were several. I have not used flash so my data may be completely inaccurate. Smile [:)] Also, don't dismiss the plug-in issue. The plug-in issue is a much bigger deal than just downloading and installing it. Many companies don't allow for third-party plugins. Getting a plug-in installed can be a major headache. Atlas does not require an installation at the client. Atlas only requires an installation of the application at the server. According to the Scott Guthrie blog entry, Atlas will run without installing anything on the web server. Atlas requires a dll in the /bin directory of an application and some script files that are a part of an application, not the web server.
I see flash as primarily used for its graphical featureset. I see Atlas and Ajax as being used for application development where data is primarily text. Yes, the Web2.0/mashup metaphor is bring together both worlds, but most application oriented data is still textual.
Anyway, thats my thoughts on the issue.


Flash has grown quite a bit and now offers very powerful programming elements. It can easily support asynchronous method invocations, serialization os complex types, data binding, and event persistent connections to the backend to avoid polling schemes - something that javascript does not support today.
Our product supports both Flash and AJAX clients in the same capacity. You can see the same examples implemented with Flash or AJAX and using the same server and the server-side .NET classes.:http://www.themidnightcoders.com/examples.
cheers,
Terry

Yes, it has been several years since they tried to do the flash ui. I figured my data was old. Smile [:)]



I think another big advantage that a pure JavaScript solution offers is that there is no need for a Flash programmer; literally the skillset. Typically, most people I have had the pleasure of working with, most can do even the most basic JavaScript, where only a very very small few can do any sort of Flash.
Cost. With Flash, not only do you need the investment into the additional skillset you need the tools/IDE.

There's a topic on the docs page that gives an overview of the relationship between Atlas and AJAX, it's titled "Understanding AJAX Applications and ASP.NET Atlas". It's athttp://atlas.asp.net/docs.

Thanks for the posts chaps, much appreciated.
>I think another big advantage that a pure JavaScript solution offers is that there is no need for a Flash programmer; literally the skillset. >Typically, most people I have had the pleasure of working with, most can do even the most basic JavaScript, where only a very very >small few can do any sort of Flash.
The thing is though, AFAIK actionscript IS javascript! I did a bit of actionscript maybe 3 4 years ago, and the 2 languages are VERY similar. I remember reading that this was intentional by Macromedia to allow easy learning for the javascript mob.
Still not seen a really convincing argument for atlas>flash though.
Thanks for the cool little discussion and the links everyone.

My 2 cents...
One of the cool things about Atlas is that it can enhance legacy ASP.NET sites (or generically, any HTML web app) incrementally. That is, you can take an existing web app and start enriching it with Atlas immediately and in small doses. You don't need to rebuild the whole web app from scratch. You can "layer in" Atlas functionality to give your existing web app incrementally richer behavior.
Further, if you use the client-side Atlas tags/functions, you can retain a nice separation of presentation and behavior for your web app. Your presentation can be built using vanilla HTML. It's behavior (how it reacts to events like "click" or "hover") can be built with Atlas tags. Thus, Atlas can help designers and developers collaborate. The designer can write the presentation (HTML) and the developer can write the behavior (Atlas tags and functions).
In Flash apps (not merely Flash eye-candy animations), in practice, the whole app is recreated from scratch. Though there are examples of hybrid HTML/Flash apps, these seem less common than Flash apps that are self-contained. Thus they tend to demand a full rewrite of your legacy app. Or, for new web apps, they tend to demand a singular approach rather than facilitating hybrid technologies that marry the best of HTML with the best of behavioral technology like Javascript.
-Russ-

Hi,

Thought i'd jump on the wagon and put in my 2 cents, so here it is.

I'm not really sure this magical world with designers doing the HTML really exists, in my experience it's been the designer doing mockups and developers doing the rest far too. At best the designer might provide the HTML for the master layout.

On the ATLAS vs Flash point, they are really 2 different fish IMO. I havn't seen too many true web applications using Flash. Also, i don't think search engines are particularly fond of flash, although i don't think they will work particularly well with ATLAS either.

Nick

Probelms with Modal Popup via server in code behind

Hi all

I am having problems while adding the modal popup dynamically to my page on the server side on a (web user control). When I set the "TargetControlId" or the "PopupControlId" like this -

ModalPopupExtender modPop = new ModalPopupExtender();
TextBox tbMsg = new TextBox();
tbMsg.ID = "tbMsg";
tbMsg.Text = "Thanks!";
modPop.ID = "modulePopup";
modPop.TargetControlID = hiddenField.ID; //made this hidden field in the user control
modPop.PopupControlID = tbMsg.ClientID;
modPop.BackgroundCssClass = "modalBackground";
modPop.X = 200;
modPop.Y = 200;

Now what is happening is that the ID's that go to the modal popup javascript (ScriptResource etc) I see that it goes in as the name of the textbox itself "tbmsg" instead of the client ID ? so I see something like document.getElementByID("tbMsg") !!!

What am I supposed to do??

Thanks in advance

Sanchita

hiddenField.ClientID will get the ID which is generated by ASP.net

Proble with Accordion Control and user control

There is one problem with Accordion Conrol

I place use control in ContentTemplate of Accordion Control.

Now problem is that when Accordion Control load first HeaderTemplate Load then page load event of User control which i placed in ContentTemplate fire.

So this is problem.

Please help me.

Thanks in advance.

Not sure at what your trying to get at here, but see if this page helps.

http://asp.net/ajax/control-toolkit/live/Accordion/Accordion.aspx


Hi Piyushp,

piyushp:

Now problem is that when Accordion Control load first HeaderTemplate Load then page load event of User control which i placed in ContentTemplate fire.

It is normal to say so. Based on the order of execution, the inner contronl's pageLoad event will be occurred before the outer control(or container)'s.

Best regards,

Jonathan.

Wednesday, March 21, 2012

Problem in finding dynamically loaded user control in javascript when using ASP.Net AJAX

Hi,
I am loading user controls dynamically in an update panel. User control loads smoothly, but when i viewsource the page, the current loaded user control can't be found there. What I found is old user control which loads when page is loaded for the first time. I have a grid view control in that user control which i want to validate using javascript, but this grid view control can't be found by javascript 'getElementById' function. How can i access grid view and other controls in javascript?

Thanks in advance.
Regards

Amjad Paracha, MCP
Software Engineer.

Seehttp://forums.asp.net/t/1149634.aspx

My guess is that your ID is incorrect when you are trying to access the control.

-Damien


amjad.paracha:

Hi,
I am loading user controls dynamically in an update panel. User control loads smoothly, but when i viewsource the page, the current loaded user control can't be found there. What I found is old user control which loads when page is loaded for the first time. I have a grid view control in that user control which i want to validate using javascript, but this grid view control can't be found by javascript 'getElementById' function. How can i access grid view and other controls in javascript?

Thanks in advance.
Regards

Amjad Paracha, MCP
Software Engineer.

What you are experiencing is the reality of how a browser actually works. The source code that you download on page load is not fixed. Its image in browser computer memory can be altered dynamically (especially by Ajax updates) and that is why the source does not reflect it. If you want to see much more closely what is going on in the page, download and install the IE Developer Toolbar (or another browser DOM viewer). This will show the current DOM and you may in fact find that the Id you are looking for is either not there or it is set as a ClientID (a property of most controls) which does not match the original ID. This would be true for instance of any ordinary control in a tab panel. They will not have the same ID you assigned on the server. As well any control in a repeating control will be assigned a new client id.

AFAIAC every develper that develops without a tool that can see the DOM as it exists is working blind. As a bonus, the IE Developer Toolbar has the ability to modify styles on the fly so you can see what they do, trace styles and a few other things.

Problem in redirection

I have a problem plz help me to sort out it

i am displaying an alert message by java script on page event.

now if user click on the "ok" button of alert then user should navigate to other page other wise not.

if i place Response.Redirect after

"ScriptManager.RegisterClientScriptBlock(this,this.GetType(),"myScript","alert(\"Your registration has been submitted and is waiting for approval from administrator. After approval/denial you will be notified at the provided email address.\");",true);"

it does not show the alert

what should i do to resolve it

help me

try this..

in html

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

<scriptlanguage="javascript"type="text/javascript">

function showmsgbox()

{

alert("hi");

}

</script>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:ButtonID="Button4"runat="server"OnClick="Button4_Click"Text="Button"OnClientClick="showmsgbox()"/></div></form>

</body>

</html>

and in code behind..

protectedvoid Button4_Click(object sender,EventArgs e)

{

Response.Redirect("~/Default8.aspx");

}

Problem in Showing Remainder in asp.net

Hi everybody

I am trying to show remainder to user who logged in the site.Whatever task he have to do is just shown in the alert box or popup window in a particular time.I used atlas timercontrol.The coding is

<form id="form1" runat="server">

<input type='text' id='myText' runat="server" visible="false" />
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>s</asp:ListItem>
<asp:ListItem>g</asp:ListItem>
</asp:DropDownList>
<cc1:ScriptManager ID="ScriptManager1" runat="server">
</cc1:ScriptManager>

</div>
<cc2:TimerControl ID="TimerControl1" runat="server" Interval="1000" OnTick="TimerControl1_Tick">
</cc2:TimerControl>
</form>

protected void TimerControl1_Tick(object sender, EventArgs e)
{
string qry = "select * from Task_det where alertstatus='y'";
DataSet ds = new DataSet();
ds = Newway.getTable(qry);
if (ds.Tables[0].Rows.Count != 0)
{
if (DateTime.Parse(ds.Tables[0].Rows[0]["AlertDt"].ToString()) == DateTime.Parse(System.DateTime.Now.Date.ToString()))
{
if (DateTime.Parse(ds.Tables[0].Rows[0]["AlertTime"].ToString()).Hour == DateTime.Parse(System.DateTime.Now.TimeOfDay.ToString()).Hour)
{
if (DateTime.Parse(ds.Tables[0].Rows[0]["AlertTime"].ToString()).Minute == DateTime.Parse(System.DateTime.Now.TimeOfDay.ToString()).Minute)
{

TimerControl1.Enabled = true;
// Response.Write("<script language='javascript'>alert('hai');</script>");
myText.Value = "Task:" + ds.Tables[0].Rows[0]["TaskTitle"].ToString();

//Response.Write("<script language='javascript'>var myTextField = document.getElementById('myText');alert(myTextField .value);</script>");
Response.Write("<script language='javascript'>window.open('showtask.aspx?Task="+ ds.Tables[0].Rows[0]["TaskTitle"].ToString().Trim() + "','REMAINDER','height=100,width=200');</script>");

TimerControl1.Interval = 60000;

}

else
{
TimerControl1.Interval = 30000;
}
}

}
}

Here i want to hide this page from the user timercontrol will start checking after the login process.But it should be behind the screen.Only alert popupwindow (showtask.aspx) is shown in particular.Is there any alternative sollution or extend this code..Please help.

Thanks& Regards

Jhanani.R

Hi Jhanani,

What do you mean by hiding the page from the user?
I can't get your point very well.
Looking forward to your reply.

Hello,

What you can do is, use WebService.

For example, the user logs in and goes straight to mypage.aspx; once he/she is at the page, you can have a javascript function running behind the background; the function checks the webservice, which check the database to see if the user has any remainder (task), if the webservice returns true (meaning there are remainders (tasks)), then cancel the loop and use window.open to open showtasks.aspx page of yours. If there's none, then continue looping and checking every 20 seconds or so.

I would use SetTimeOut, don't use for loop or while loop, or any loop... =)


I mean to say i dont want a separate page for clock tick it will be common for all the pages am using in project.Any pages i can navigate but the clock should

tick and check the matching time and give alert.I have completed this using atlas control.But my friends are suggesting to do it with thread and log file.log file to hold the clock tick time.

Do u have any idea please tell

Jhanani


So here is your situation:

You have a page will continualy check if there is an event for the current user, if so, a remider will show. And you intend to hide this page from the user because it actually doesn't have any visual component.

I think you can use amaster page. It works as the template of all pages in your application.

Move the code above into it so that all pages will have this function.

JananiSharma:

my friends are suggesting to do it with thread and log file.log file to hold the clock tick time.

The customer will use a browser to visit your application, but you can't start a thread on the client via the customer's browser. If you application is windows based, it's a good idea, but not for a web based application.


ya i used atlas timer control in master page and call alert popup if event occurs in the particular time.But my team leader asked me to try in windows service.Is it possible


Yes, it's a feasible solution.

You can start a thread in the windows service to monitor if there is any reminder to show. But it's necessory to install the windows service on each machine.


Will you give one example.

And in timer control when it shows alert message that time the page which is running get changes in styles .For me font size is changing when the alert message appears.But for the next clock tick it again come to previous state.Please tell me solution for this.

Thanks&Regards,

Jhanani.R


Please follow this tutorial for how to create a windows service: http://msdn2.microsoft.com/en-us/library/aa984464(VS.71).aspx

Also note that now your application isn't a web/browser based application, you are doing windows programming now.

For more information about Windows service, please read this: http://msdn2.microsoft.com/en-us/library/d56de412(VS.80).aspx


Raymond,

If the poster uses a windows service to track the tasks from the database, how does the windows service communicate with the user(s) from the web app? Does the web app have to start the communcation with the windows service first?

I am asking because I don't know; and also i have a feeling that using windows service will create more works. May be the poster (forgot what the name is) should talk with the team leader again.

And installing the service on each system is not a good idea either. What if it's a public system? Plus, you need to program to when the windows service should run and when it should not. This is when you need to use ActiveX. Or is there an easier way, or am I over thinking? I just give my opinion so that the poster should not use windows service if i'm correct ...


Raymond, clear me up if i'm talking nonsense, thanks ... =)


WishStar99:

Raymond,

If the poster uses a windows service to track the tasks from the database, how does the windows service communicate with the user(s) from the web app? Does the web app have to start the communcation with the windows service first?

I am asking because I don't know; and also i have a feeling that using windows service will create more works. May be the poster (forgot what the name is) should talk with the team leader again.

And installing the service on each system is not a good idea either. What if it's a public system? Plus, you need to program to when the windows service should run and when it should not. This is when you need to use ActiveX. Or is there an easier way, or am I over thinking? I just give my opinion so that the poster should not use windows service if i'm correct ...


Raymond, clear me up if i'm talking nonsense, thanks ... =)

Hi,

Yes, as you've mentioned, those problems do exist.

To implement the reminder with Timer on the web page is a solution, but not good enough. The thing is that if I want to receive reminder, I have to keep the browser open. While windows service can keep running without any UI.

For the windows service here, it doesn't need to communicate with the web app. It's a separate application.


Sorry i forgot to say that am developing project in web application.I want to know timer control in windows service.Thats y i asked.Will you please tell y the styles are changing after the alert message

Thanks& Regards,

Jhanani.R


Sorry i forgot to say that am doing project in web application.But i wanna know the windows service .Thats y i asked.Please tell y font changes during alert message.

Thanks&Regards,

Jhanani.R


Raymond,

I know it's a seperate application. My concern is, how does the user from the web application knows that there's a new task for him or her? Does the web app page have to communicate with the windows service somehow? Here's what I understand so far:

You have a windows service timer which detects if there's any tasks for a certain user or not, if yes, then what will happen? How does the windows service notify the user from the web application?

Raymond, again, i'm not debating with you, but i want to know so i can learn from it =) thanks ....


Okay, forget it ... i'll leave you alone. LOL.

I'll check back when the problem is solved.


JananiSharma ... let us know what's the solution is ... thanks ...

Problem In Update Panel...

Hello,

I have a Set of Buttons which are to be showed in some condition. Means Some of My buttons I want to show if User has given some conditions. So I put them in an Update Panel. Now if any button in this panel is having Server.Transfer method then it shows error and do not allow to leave that Update Panel. How to overcome this problem ? (Response.Redirect works but I have to use Server.Transfer.)

Why you need to use Server.Transfer? Can you postback to a different page?

My 2 cents about Atlashttp://alpascual.com/blog/al/archive/2006/07/18/215.aspx

http://alpascual.com/blog/al/archive/2006/07/13/207.aspx

Cheers

Al

Problem layout calendar-control

Hello,

I have a page with an update-panel. In the update panel a user control is used on which a calender control is used to pick a date. When I click on the image button which is used as popup button, the calender appears, but no layout is applied. When I put the user control outside of the update panel, everything works as expected.

I used the IE developer toolbar to examine the CSS and the references and I noticed that when I put everything outside the update panel an extra link-reference is made to an embedded resource, probably the CSS for the calendar control. When I use the update-panel this reference does not appear and the layout is not applied.

Has anyone experienced this behaviour? Is this a bug? The workaround is pretty easy: do not use the update panel or explicitly reference the CSS embedded resource, but it is not the nice way to solve this :-)

Suggestions?

Gr,

Jelle

Hi

Would you please create a simple reproduce of this issue? I'd like to have a test on your simple reproduce to see whether it really is a bug or not.

Cause you already have a pretty easy workaround,the post can be marked "resolved",but if you provide a simple reproduce, I will work over it to see whether it really is a bug or not.

Thanks

Problem Loading URL into Div

On a website I am working on I am trying to load another page into a div on the the page the user does his work from. What I have works correctly in FireFox, but not in IE. I've rummaged Google for quite a bit and found similar problems, but no set solutions.

Here is the JavaScript I have to load a URL into a Div:
function setResponseHtml(pUrl, pDiv) {
var lHttp = getHTTPObjectHtml();
var lUrl = pUrl;
lUrl = lUrl.replace("+","%2b");
if (isBusy) {
lHttp.onreadystatechange = function () {}
lHttp.abort();
}

lHttp.open("GET", lUrl , true);
lHttp.onreadystatechange = function() { getHttpResponseText(pDiv, lHttp); };

if (window.XMLHttpRequest) { // Mozilla check
if (!isBusy) {
isBusy = true;
lHttp.send(null);
}
} else { // IE Check
isBusy = true;
lHttp.send(null);
}
}

function getHTTPObjectHtml() {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
return http_request;
}

function getHttpResponseText(pDiv, pHttp) {
var lHttp = pHttp;

if (lHttp == null) // just in case!
lHttp = gHttp;

if (lHttp.readyState == 4) {
isBusy = false;

var status = "";
try {
status = lHttp.statusText;
if (lHttp.status == 200) {
var htmlDocument = lHttp.responseText;
document.getElementById(pDiv).innerHTML = htmlDocument;
}
} catch(e) {
status = "Trouble accessing it";
document.getElementById(pDiv).innerHTML = e.message;
}
} else {
if (getAjaxLoadingMessage() != '' && getAjaxLoadingMessage() != null) {
// only display a loading message if it is defined
setVisible(pDiv, true);
document.getElementById(pDiv).innerHTML = getAjaxLoadingMessage();
}
return;
}
}

var gAjaxLoadingMessage = '<b>Loading...</b>';

function setAjaxLoadingMessage(pMessage) {
gAjaxLoadingMessage = pMessage;
}

function getAjaxLoadingMessage() {
return(gAjaxLoadingMessage);
}

This is called from the HTML via: setResponseHtml(urlString, divString);
urlString is a string containing the URL that I wish to load in the div, and divString a string containing the id of the div I wish to load the URL into.

I've tested my code on IE before and it worked properly with a very small file with nothing in except for a couple words. I think the problem may go back to these pages, both the one the users calls the function from and the page to be loaded, contain SharePoint Web Parts. That is the only difference I can think of between the original pages I used to test the code and the pages I am working with now.

An error occurs in IE when trying to load the Div, the error being "[object Error]" and the error message being "Unknown runtime error" if I print e and e.message respectively from the getHttpResponseText function.

This is the section of code where the error occurs:
try {
status = lHttp.statusText;
if (lHttp.status == 200) {
var htmlDocument = lHttp.responseText;
if (gAjaxForeground) {
setVisible(pDiv, true);
}
document.getElementById(pDiv).innerHTML = htmlDocument;
}
} catch(e) {
status = "Trouble accessing it";
document.getElementById(pDiv).innerHTML = e.message;
}

I can't figure out exactly why the error is happening, nor how to correct it. If I change the line "document.getElementById(pDiv).innerHTML = htmlDocument;" to "document.getElementById(pDiv).innerHTML = 'Any text here';" I recieve no errors, so apparently IE doesn't like setting the innerHTML of the page to be loaded to the statusText. Why that is and how to fix it is what I'm hoping to find out.

Just a quick question... why aren't you using IFRAME (or whatnot) for something like this. If you're loading an entire page, you're going to have issues like duplicate HTML and BODY tags.

-Damien


The main reason behind using a DIV is because the content from the page being loaded into the div is dynamic content, and the DIV will resize automatically if needed. One other thing to note is that this DIV tag isn't always visible on the page. When the user mouses over an item on the page a pop-up comes up displaying additional information about the object, as well as allowing the user to edit such information, which is where the AJAX comes in - allowing the user to edit the information without straying away from this page, and the page being loaded into the pop-up is the page that has done the update and is displaying the results. I haven't worked with IFRAMEs that much, but from my understanding all of this is not that possible with them - correct me if I'm wrong. I have thought about about duplicated tags, but in the past and during my testing I've never experienced any problems by having such.


Well, you can't push an HTML string into an IFRAME, but you can load a URL. Think of an IFRAME like your DIV; it's a container. You can perform client-side logic with it (e.g. show/hide) and it's the way to host another page inside a page (like you are doing).

Seehttp://en.wikipedia.org/wiki/IFrame andhttp://msdn2.microsoft.com/en-us/library/ms537627.aspx.

Using the DIV and having duplicate HTML and BODY (not to mention HEAD, etc) will cause issues; plus it's not well formed at all.

Hope this helps you.

-Damien


With a bit of help from someone and a bit more searching online I discovered the cause of my problem. Thought I'd post the actual reason for the problem and my resolution here for anyone that might be having similar issues.

The reason for the Runtime Error were Element Prohibitions within the HTML. The DIV that I was trying to insert into was surrounded by FORM tags and the page I was trying to insert into the DIV had FORM tags within it. To put it simply: You cannot have a FORM inside of a FORM.

See this URL for more information: http://www.w3.org/TR/xhtml1/#prohibitions

IE upholds this, where as Firefox doesn't care and just renders it on screen how it thinks the output should look which is why I was having this problem only in IE.

I couldn't remove the FORM tags because the website I am working on is a SharePoint site that uses Web Parts (which are required to have FORM tags around them - if I removed them I got errors that bluntly said FORM tags were needed). So, to overcome this I modified the function getHttpResponseText() (See my first post to view the code). Rather than dump the repsonseText straight into the innerHTML of the DIV tag I used indexOf to find the start and end of the data that I specifically wanted (in my specific case one table on the page) and used a substring to cut that out from the responseText and dump that into the innerHTML of the DIV, thus eliminating the FORM tags.

No iFrames involved and everything works splendid. :p

On a side not, I went to set my thread to 'Resolved' and it was already set at that. I definitely never did that since I didn't have a resolution until today. If code in the forum did that, I would correct it ASAP. If a person did that, I would smack him/her for not reading the thread properly. Suggesting to use an iFrame as an alternative was never a solution. It was just what I said - an alternative where the original problem still remained. The reason for the error, nor a solution to fix it never existed in this thread until the post I am making now.