UltimateEditor
Topic: Re: UltimateEditor always is focused even when setting focus on textbox
Karamasoft Support Forums

Page 1 of 1 (3 items)


Posted by goodfella on 04-26-2007 1:26 PM
Hi there,

I am trying to set focus on a textbox when a dropdown selection is made. Upon choosing the "yes" field (value 1), the txtPlacement should have focus. This works fine until I add the Editor control. It seems the editor control always takes focus, no matter what.

protected void ddlPlacement_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlPlacement.SelectedValue == "1")
        {
            txtPlacement.Enabled = true;
            SetFocus(txtPlacement);
        }
        else
        {
            txtPlacement.Enabled = false;
        }
    }

    private void SetFocus(string txtbox)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder("");

        sb.Append("<script language=\"JavaScript\">");
        sb.Append(" document.forms[0].item(\"" + txtbox + "\").focus()");
        sb.Append("</script>");

        if (!IsStartupScriptRegistered("setFocus"))
        {
            RegisterStartupScript("setFocus", sb.ToString());
        }
    }

Thanks!

Posted by Karamasoft on 04-26-2007 2:24 PM
Try setting SetFocus property, which gets or sets a value that indicates whether the editor text box will be focused on page load, of your UltimateEditor control to False. Its default value is True.

Posted by goodfella on 04-27-2007 12:21 AM
Thanks! Worked just fine... One of those things I should've tried, sorry about that Smile

Thanks again!