smart navigation works this way.
1) when the page is rendered, client script creates a hidden frame and the
form target is changed to this hidden frame.
2) when the page is posted, the postback form is rendered in the hidden
frame. client script then copies the dom model from the hidden frame to
current frame.
this has several side effect on script rendered on postback.
1) any inline script run in the hidden frame. so if it just changes the dom,
ok.
2) any onload script that chages the dom will be running a race with the
copy script.
3) new script functions created on postback exist only in the hidden frame.
also the server doesn't know if smart navigation is being used, only thats
its enabled, as all smart navigation logic is done in client script.
enabling smart navigation just causes the smart navigation client script to
be rendered, but the client script makes the decision.
-- bruce (sqlwork.com)
[quoted text, click to view] "Bob" <bobjiang@yahoo.com> wrote in message
news:#JgmGbn5DHA.2760@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I have a function to inject the client-side script from an ASP.NET server
> control to move the cursor. It works perfect when the Smart Navigation is
> turned off. However when the Smart Navigation is on, it would not work. I
> understand Smart Navigation does things differently by its design. I was
> just wonderig whether there is a way to walk around it. Thanks for your
> help.
>
> The below is the code snippets:
>
> Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> DropDownList1.SelectedIndexChanged
> If Me.TextBox1.Text.Trim = "" Then
> SetInputFocus("TextBox1")
> DropDownList1.SelectedIndex = -1
> Return
> End If
> End Sub
>
> Public Sub SetInputFocus(ByVal ctlName As String)
> Dim st As New System.Text.StringBuilder
>
> st.Append("<script language=javascript>")
> st.Append("document.getElementById(")
> st.Append("""")
> st.Append(ctlName)
> st.Append("""")
> st.Append(").focus();")
> st.Append("</script>")
>
> If Not HttpContext.Current Is Nothing Then
> Dim page As System.Web.UI.Page =
> CType(HttpContext.Current.Handler, System.Web.UI.Page)
> If Not page Is Nothing Then
> page.RegisterStartupScript("InputFocusHandler",
> st.ToString())
> End If
> End If
> End Sub
>
>
>
>