/    Sign up×
Community /Pin to ProfileBookmark

I To write on an aspx page

I am creating an aspx Page.Iam doing some validations on the page.But instead of using alert I want to write the message on the page itself.when I use document.write ,it actually writes on a new document.but i want to write on the same page with allthe asp.net controls.

thanks in advance

joe

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ricpApr 29.2007 — Once rendered you want to amend, rather than write to the page, which as you've found clears any content in the process.

Several methods are available, such as the .innerHTML property:
<i>
</i>document.getElementById("someElementID").innerHTML = "&lt;strong&gt;ooh, I'm bold&lt;/strong&gt;";

Or you can go down the dynamic method and create both the html and the content like so:
<i>
</i>var myEl = document.getElementById("someElementID");
var myBoldTag = document.createElement("strong");
var myText = document.createTextNode("oooh, I am bold");
myBoldTag.appendChild(myText);
myEl.appendChild(myBoldTag);

Where you create each separate element/content then appended onto the page. Both of these methods do not destroy the content already rendered.
×

Success!

Help @drsmilecreator spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...