开发者

SetFocus from MasterPage of a Content page TextBox

I am Using a "gamabhana" Language script to enter text in "Marathi" Language in TextBox which is on Content Page and i need set focus before load due to following error:-

Error: Microsoft JScript runtime error: 'null' is null or not an object. while loading the page. it asks for registerstartupscript focus on that control.

On Master Page finding the control which is on Content Page: script type="text/jscript" 开发者_开发知识库language="jscript" gphObj1 = new gamabhanaPhoneticHandler('ctl00_MainContent_txtVoterName', 'devanagari', 'roman', '#gamabhana#');

script

any idea?


You can find controls in content page from master page like this

TextBox txtBox = ContentPanel1.FindControl("txtVoterName") as TextBox;

if (txtBox != null)
{
   ...
} 


here the solved code...

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:DropDownList ID="drpLanguage" runat="server" onchange=" return LanguageList_onchange()">

                     <asp:ListItem value="english">English</asp:ListItem>
                     <asp:ListItem value="__malayalam__">Malayalam</asp:ListItem>
                        <asp:ListItem value="__bengoli__">Bengali</asp:ListItem>
                         <asp:ListItem value="__devanagari__">Hindi</asp:ListItem>
                          <asp:ListItem value="__gujarati__">Gujarati</asp:ListItem>
                           <asp:ListItem value="__gurumukhi__">Gurmukhi</asp:ListItem>                          
                            <asp:ListItem value="__odiya__">Oriya</asp:ListItem>
                             <%--<asp:ListItem value="tamil">Tamil</asp:ListItem>--%>
                              <asp:ListItem value="__telugu__">Telugu</asp:ListItem>
                              <asp:ListItem value="__kannada__">Kannada</asp:ListItem>
                              <asp:ListItem value="__urdu__">Urdu</asp:ListItem>


                    </asp:DropDownList>
                    <asp:TextBox ID="TextBox1" runat="server" Height="136px" TextMode="MultiLine" 
        Width="203px"></asp:TextBox>

    <br />
    <br />
    <br />
    <br />
       <%-- <script src="Scripts/fileio.js" type="text/javascript"></script>--%>
    <script src="Scripts/GA0010.js" type="text/javascript"></script>
    <script src="Scripts/GA0640.js" type="text/javascript"></script>
    <script src="Scripts/GAcommunicator.js" type="text/javascript"></script>
    <script src="Scripts/gamabhanaLib.js" type="text/javascript"></script>
    <%--<script src="Scripts/gamabhanaSCHelper.js" type="text/javascript"></script>--%>
    <script src="Scripts/GA1000.js" type="text/javascript"></script>
    <%--<script src="Scripts/wysiwyg.js" type="text/javascript"></script>
--%>
    <SCRIPT LANGUAGE=javascript>

        var gp;
        function LanguageList_onchange() {

            var lang = document.getElementById('<%=drpLanguage.ClientID  %>').value;
            alert(lang);
            gp = new gamabhanaPhoneticHandler('<%=TextBox1.ClientID %>', lang, '', '');
            //            gp.MrAutoCor = true;
            //            gp.UpdateAjaxSpellCheck(true);
            ////           
        }
        //        
        //-->
</SCRIPT>
    <br />
</asp:Content>


Use the bellow link and follow the instruction you will get appropriat answer "http://www.codeproject.com/Articles/67944/Hindi-Marathi-Transliteration-ASP-NET-Custom-Contr"

Step 1: Add DLL reference to your web from above link.

Step 2: Register the tag prefix as :

<%@ Register Assembly="TransliterateTextboxControl" Namespace="TransliterateTextboxControl" TagPrefix="cc1" %>

Step 3: Apply to textbox as:

<cc1:TransliterateTextbox ID="searchExpressionTextBox" runat="server" Width="410px" CssClass="searchInputBoxes" Height="22px" EnableKeyboard="true" KeyboardLayout="ENGLISH"  DestinationLanguage="ENGLISH" Text="">
</cc1:TransliterateTextbox>

Step 4: On RadioButton checkChanged Event:

protected void Radio_CheckedChanged(object sender, EventArgs e)
    {
        searchExpressionTextBox.Text = string.Empty;
          searchExpressionTextBox.KeyboardLayout = TransliterateTextbox.SupportedKeyboardLayouts.DEVANAGARI_PHONETIC;
        searchExpressionTextBox.DestinationLanguage = TransliterateTextbox.SupportedLanguages.MARATHI;      
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜