JB4375
asked on
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.MaintainScrollPositio nOnPostBac k = 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!!
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();
//]]>
<
ASKER
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.
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.
ASKER
Anyone got another suggestion?
ASKER
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="/wEPDwULLTE2NTcyMDU 2OTAPZBYCA gMPZBYKAis PEGRkFgFmZ AJfDw8WAh4 HVmlzaWJsZ WhkZAJhDw8 WAh8AaGRkA mMPDxYCHwB oZGQCaw8PF gIeBFRleHQ FD21lZGN0c lxtaGJvd21 hbmRkGAEFH l9fQ29udHJ vbHNSZXF1a XJlUG9zdEJ hY2tLZXlfX xYDBQpDaGV ja0JveDE0B QpDaGVja0J veDE1BQpDa GVja0JveDE 2RqjaN1Nsa 8jJg+fPR0j 1BzdFJyU=" />
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWIQK02c+8DwLs0bL rBgLs0fbZD ALs0Yq1BQL s0e58AuzRg tgJAuzRxsY PAuzR2qEIA vKJkN4OAtf N8vACAsu8p OwDApzX4pw NAp7szM0JA tWv9ZwNApT P1bcBAr2tm 40PAv+D0vs CAsHzqacFA sON7+UMAqH w554IAo3t9 PMHAqrU7OE DAqvU7OEDA qzU7OEDAoL kp7wJAoLkq 7wJAoLkn7w JArDU7OEDA qHU7OEDAqL U7OEDAv+x2 Y4EAtLzIQL cu4S2BBMVs vhKr2+j0ZY SRIqw+TnBk AZk" />
</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="/wEPDwULLTE2NTcyMDU 2OTAPZBYCA gMPZBYKAis PEGRkFgFmZ AJfDw8WAh4 HVmlzaWJsZ WhkZAJhDw8 WAh8AaGRkA mMPDxYCHwB oZGQCaw8PF gIeBFRleHQ FD21lZGN0c lxtaGJvd21 hbmRkGAEFH l9fQ29udHJ vbHNSZXF1a XJlUG9zdEJ hY2tLZXlfX xYDBQpDaGV ja0JveDE0B QpDaGVja0J veDE1BQpDa GVja0JveDE 2RqjaN1Nsa 8jJg+fPR0j 1BzdFJyU=" />
</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.valu e = eventTarget;
theForm.__EVENTARGUMENT.va lue = eventArgument;
theForm.submit(); ******** This is where it blows up ************************** ***
}
}
//]]>
</script>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWIgK02c+8DwLs0bL rBgLs0fbZD ALs0Yq1BQL s0e58AuzRg tgJAuzRxsY PAuzR2qEIA pTkj+UKAvK JkN4OAtfN8 vACAsu8pOw DApzX4pwNA p7szM0JAtW v9ZwNApTP1 bcBAr2tm40 PAv+D0vsCA sHzqacFAsO N7+UMAqHw5 54IAo3t9PM HAqrU7OEDA qvU7OEDAqz U7OEDAoLkp 7wJAoLkq7w JAoLkn7wJA rDU7OEDAqH U7OEDAqLU7 OEDAv+x2Y4 EAtLzIQLcu 4S2BCeIMEk TpaX6M0xNu OzNv9i7wVT y" />
</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!!
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="/wEPDwULLTE2NTcyMDU
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWIQK02c+8DwLs0bL
</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="/wEPDwULLTE2NTcyMDU
</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.valu
theForm.__EVENTARGUMENT.va
theForm.submit(); ******** This is where it blows up **************************
}
}
//]]>
</script>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWIgK02c+8DwLs0bL
</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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"MaintainScrollPostition is not supported on pages with partial rendering turned on"