当我在asp.net web应用程序的sub方法中使用它时,按钮控件提示null引用异常

时间:2018-02-05 06:54:06

标签: asp.net vb.net web-applications nullreferenceexception

我点击它时有一个按钮,它应该切换应用程序的语言或文化,问题是我alawys获取该按钮的null referece异常 这是我的vb代码

 Protected Overrides Sub InitializeCulture()

    If ddlLanguages2.InnerText.ToString.Trim.Equals(("English").ToString.Trim) Then
        ddlLanguages2.InnerText = "عربي"
        Dim selectedLanguage As String = "en-us"
        UICulture = "en-us"
        Culture = "en-us"
        Thread.CurrentThread.CurrentCulture =
            CultureInfo.CreateSpecificCulture(selectedLanguage)
        Thread.CurrentThread.CurrentUICulture = New _
            CultureInfo(selectedLanguage)

    ElseIf ddlLanguages2.InnerText.ToString.Trim.Equals(("عربي").ToString.Trim) Then
        ddlLanguages2.InnerText = "English"
        Dim selectedLanguage As String =
           "ar-kw"
        UICulture = "ar-kw"
        Culture = "ar-kw"
        Thread.CurrentThread.CurrentCulture =
            CultureInfo.CreateSpecificCulture(selectedLanguage)
        Thread.CurrentThread.CurrentUICulture = New _
            CultureInfo(selectedLanguage)

    End If
    MyBase.InitializeCulture()
End Sub



Protected Sub ddlLanguages_SelectedIndexChanged(sender As Object, e As EventArgs)

    InitializeCulture()

End Sub

当它到达第一个&#34时停止;如果"顺便说一句,任何控件都不能在InitializeCulture中工作

  <button id="ddlLanguages2" style="margin-top: 5px" runat="server" 
  onserverclick="ddlLanguages_SelectedIndexChanged">
                                    عربي
                        </button>

任何帮助将不胜感激

0 个答案:

没有答案