JavaScript to Reset page ASP.NET 2.0.

S

sck10

Hello,

I have a table with some controls in it, but it is not rapped in a form. I
also have a button for reseting the page. When I click the button, the page
resets, but I get the following error: "Done, but with errors on the page".
I am trying to figure out a way to use JavaScript in my master page that can
be used for all my content pages. Any help with this would be appreciated.

Thanks, sck10

<%@ Page Language="VB" StylesheetTheme="Default"
MasterPageFile="~/template/mpColumn02.master" CodeFile="ipm_survey.aspx.vb"
Inherits="ipm_survey" title="Untitled Page" Trace="false" %><asp:Content
ID="Content1" ContentPlaceHolderID="cphMainContent" Runat="Server">

<table width="95%" class="tblOutline">
<caption>IPM Survey Questions</caption>

<tr><td style="height:10px" colspan="5">&nbsp;</td></tr>

<!-- Question HRID -->
<tr visible="false">
<td style="width:4%; text-align:right;"><asp:Label ID="lblHRID"
Runat="server" /></td>
<td style="text-align:left;" colspan="4"><asp:TextBox id="txtHRID"
Columns="15" runat="server" />
&nbsp;<span class="RedM">(optional)</span></td>
</tr>

<!-- Question Region -->
<tr>
<td style="width:4%; text-align:right;"><asp:Label ID="lblRegion"
Runat="server" /></td>
<td style="text-align:left;" colspan="4"><asp:DropDownList
ID="ddlRegionType" runat="server" /></td>
</tr>

<td style="width:100px; text-align:center;"><a href="#"
onclick="reset();return false"
onmouseover="status='Reset';return true" onmouseout="status=''">
<img src="../../images/icons/b_clear_bold.gif" style="border-style:none;"
alt="Reset" /></a></td>
</table

Script from the Master Page
----------------------------------------------------
<script language="Javascript" type="text/Javascript">
<!--
document.myform.reset();
//-->
</script>
 
W

Walter Wang [MSFT]

Hi sck10,

Thank you for your post.

When you get the following error "Done, but with errors on the page" on the
status bar, you can double click on it to view a detailed description of
the error.

Javascript files or functions defined in master page can be used in content
page. But I saw that you didn't enclose the javascript code in a function,
which means it will run everytime the page loads, and since then the
document is not fully loaded, referencing controls on the page will result
error.

Actually the reset() function of html form can be called directly, you
don't have to define a function in master page and let the content page
call it.

At last, when ASP.NET merges the master page and the content page, the form
name gets changed to pre-defined 'aspnetForm', not the name you defined in
master page, this is by design. We can use 'document.forms[0]' to reference
the form.

Hope this helps. Please feel free to post here if anything is unclear.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top