MS Jscript runtime error: Object doesn't support this property of method.

I have a ASP.Net form that uses JScript to send a popup message when the text fields are left blank. I've used this code a least 10 times but on this time it seems to have a problem with this line which I've been using nearly as long: Page.MaintainScrollPositionOnPostBack = True

I noticed during testing that my page was loading but doing so with errors. I started the debug process and came up with the following:

Code sections and error messages below.

Thanks!!
VB Backend Page:

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Page.MaintainScrollPositionOnPostBack = True
        strAudixNeed = "No"
        strRushNeed = "No"
        strWiringNeed = "No"
        strDate = Now
        strUser = (Request.ServerVariables("AUTH_USER"))
        If InStr(strUser, "domain\") Then
            strUser = Replace(strUser, "domain\", "")
        End If
        If InStr(strUser, "domain\") Then
            strUser = Replace(strUser, "domain\", "")
        End If
        Label48.Text = "domain\" & strUser

    End Sub

JSCRIPT Sub to Send Message:

    Public Sub UserMsgBox(ByVal F As Object, ByVal sMsg As String)
        Dim sb As New StringBuilder()
        Dim oFormObject As System.Web.UI.Control = Nothing
        Try
            sMsg = sMsg.Replace("'", "\'")
            sMsg = sMsg.Replace(Chr(34), "\" & Chr(34))
            sMsg = sMsg.Replace(vbCrLf, "\n")
            sMsg = "<script language='javascript'>alert('" & sMsg & "');</script>"
            sb = New StringBuilder()
            sb.Append(sMsg)
            For Each oFormObject In F.Controls
                If TypeOf oFormObject Is HtmlForm Then
                    Exit For
                End If
            Next
            oFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(sb.ToString()))
        Catch ex As Exception
        End Try
    End Sub

form.aspx[dynamic]  ***Occurs during debug process***

<script type="text/javascript">
//<![CDATA[

theForm.oldSubmit = theForm.submit;
theForm.submit = WebForm_SaveScrollPositionSubmit;

theForm.oldOnSubmit = theForm.onsubmit;
theForm.onsubmit = WebForm_SaveScrollPositionOnSubmit;
Sys.Application.initialize();
//]]>
<

Open in new window

LVL 1
JB4375Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Do you have partial rendering enable on the page?

"MaintainScrollPostition is not supported on pages with partial rendering turned on"
0
JB4375Author Commented:
No... no partial rendering.
In researching I saw where some of this could be handled via AJAX and I don't have that.
I also saw code for it in Javascript, but the only the only place that it exists is in the sub that I referenced above.
0
JB4375Author Commented:
Anyone got another suggestion?
0
JB4375Author Commented:
I've been testing this for a while and I've come up with some interesting situations.
First, the IF statements weren't that well formed, and I've redone those to produce more desirable results.
Second, if I set the dropdownlist autopostback="false" I can click submit, and because some of the form in still imcomplete it produces my message to complete the form, but  the text boxes populate correctly and no javascript error is produced.
Third, if I set the DDL autopostback="true" and select an option from it the javascript error is produced, and clicking submit again produces my message but also clears the javascript error.
Finally:
Viewing Source with APB="False" shows this:
    <form name="form1" method="post" action="form.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2NTcyMDU2OTAPZBYCAgMPZBYKAisPEGRkFgFmZAJfDw8WAh4HVmlzaWJsZWhkZAJhDw8WAh8AaGRkAmMPDxYCHwBoZGQCaw8PFgIeBFRleHQFD21lZGN0clxtaGJvd21hbmRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYDBQpDaGVja0JveDE0BQpDaGVja0JveDE1BQpDaGVja0JveDE2RqjaN1Nsa8jJg+fPR0j1BzdFJyU=" />
</div>
<div>
 <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWIQK02c+8DwLs0bLrBgLs0fbZDALs0Yq1BQLs0e58AuzRgtgJAuzRxsYPAuzR2qEIAvKJkN4OAtfN8vACAsu8pOwDApzX4pwNAp7szM0JAtWv9ZwNApTP1bcBAr2tm40PAv+D0vsCAsHzqacFAsON7+UMAqHw554IAo3t9PMHAqrU7OEDAqvU7OEDAqzU7OEDAoLkp7wJAoLkq7wJAoLkn7wJArDU7OEDAqHU7OEDAqLU7OEDAv+x2Y4EAtLzIQLcu4S2BBMVsvhKr2+j0ZYSRIqw+TnBkAZk" />
</div>
Viewing Source with APB="True" shows:

<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2NTcyMDU2OTAPZBYCAgMPZBYKAisPEGRkFgFmZAJfDw8WAh4HVmlzaWJsZWhkZAJhDw8WAh8AaGRkAmMPDxYCHwBoZGQCaw8PFgIeBFRleHQFD21lZGN0clxtaGJvd21hbmRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYDBQpDaGVja0JveDE0BQpDaGVja0JveDE1BQpDaGVja0JveDE2RqjaN1Nsa8jJg+fPR0j1BzdFJyU=" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();   ******** This is where it blows up *****************************
    }
}
//]]>
</script>

<div>
 <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWIgK02c+8DwLs0bLrBgLs0fbZDALs0Yq1BQLs0e58AuzRgtgJAuzRxsYPAuzR2qEIApTkj+UKAvKJkN4OAtfN8vACAsu8pOwDApzX4pwNAp7szM0JAtWv9ZwNApTP1bcBAr2tm40PAv+D0vsCAsHzqacFAsON7+UMAqHw554IAo3t9PMHAqrU7OEDAqvU7OEDAqzU7OEDAoLkp7wJAoLkq7wJAoLkn7wJArDU7OEDAqHU7OEDAqLU7OEDAv+x2Y4EAtLzIQLcu4S2BCeIMEkTpaX6M0xNuOzNv9i7wVTy" />
</div>
Can anyone tell me why this is blowing up when I have another page that uses this exact same code on another page with no issues??
Thanks!!

<div class="column1">
<asp:Label ID="Label10" runat="server" Text="RequestType:"></asp:Label><br />
<asp:DropDownList ID="DropDownList8" tabindex="8" runat="server" AutoPostBack="true" Width="200px">		                <asp:ListItem Value="Select Type">Select Type</asp:ListItem>
<asp:ListItem>Install</asp:ListItem>
<asp:ListItem>Move</asp:ListItem>
<asp:ListItem>Upgrade</asp:ListItem>
</asp:DropDownList> 
</div><!-- end class column1-->

Protected Sub DropDownList8_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList8.SelectedIndexChanged
        If DropDownList8.SelectedItem.Text = "Move" Then
            TextBox11.Text = "Not Applicable"
            TextBox13.Text = "Not Applicable"
        ElseIf DropDownList8.SelectedItem.Text = "Upgrade" Then
            TextBox11.Text = "Not Applicable"
            TextBox13.Text = ""
        Else
            TextBox11.Text = ""
            TextBox13.Text = ""
        End If
    End Sub

Open in new window

0
JB4375Author Commented:
This is the dumbest thing I've ever seen but I've figured it out. I commented everything out with the exception of the dropdown, and the selectedIndexChanged sub on the backend, and it works.
I gradually added pieces back in on both pages until I found the cuprit which turned out to be the submit button as would seem to be indicated by the error.
I deleted the submit button and added it back from the toolbox: failed.
I deleted the submit button and copied/edited the clear button next to it: failed.
I changed the name of the submit button, the sub, and the css tag to button1 and it works.
In fact, it works with all of the other items it was throwing errors on like the javascript msg box, and Page.MaintainScrollPositionOnPostBack = True as well.
Best guess: Visual Studio through some errant character or code in there and changing the name forced it to rewrite it.
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.