SA.
SA.

Reputation: 752

reading content of .aspx using javascript

i am using javascript to read the content of .aspx page. but i am not able to read it. i am using javascript as:

function edit(headtext,totext, bodytext, footertext){
        alert('lll');
         //var xmlDoc=new ActiveXObject("MSXML.DOMDocument");
         xmlDoc.async="false";
         xmlDoc.load("theme3ex.aspx");
         var students = xmlDoc.documentElement;
         alert('0000');
         var student = students.childNodes(0);
         document.getElementById('txtareahead').innerHTML = headtext;
         document.getElementById('txtareato').innerHTML = totext;
         document.getElementById('txtareabody').innerHTML = bodytext;
         document.getElementById('txtareafooter').innerHTML = footertext;
         location.href = "MailSender.aspx";
         }

is there any problem eith my javascript..

Upvotes: 0

Views: 241

Answers (2)

Curtis
Curtis

Reputation: 103358

I agree with @Spudley's point.

It's also worth mentioning that if the textboxes such as txtareahead are ASP.NET TextBox Controls, then the ID's will have most likely changed during rendering.

Upvotes: 0

Spudley
Spudley

Reputation: 168685

First problem is that you've commented out the line which creates the AJAX object, so none of the subsequent code will work because they're trying to access an object which doesn't exist.

Second problem is that even if you uncomment that line, it's using Activex/MSXML which will only work with IE (and even then only older versions of IE).

In short, your code isn't good, and needs to be entirely redone rather than being fixed.

My recommendation is that you find a more up-to-date example of how to do AJAX code. Possibly even just use a good quality Javascript library like JQuery.

Upvotes: 2

Related Questions