为什么当我将启用设置为假然后在 asp.net 中回发页面时,radComboBox 中的 SelectedValue



为什么当我将"启用"设置为假然后在 asp.net 中回发页面时,radComboBox 中的 SelectedValue 为空?

我的页面中有一个radComboBox,它通过Web服务方法填充。 在服务器端,当我设置启用为假并且回发我的页面时,我无法获取radcombobox的选定值,并且选择的值为空。请帮帮我...

代码在我的页面.aspx

    <telerik:RadComboBox ID="radCmbOwnerList" runat="server"  EnableLoadOnDemand="true"
 EnableVirtualScrolling="true" MinFilterLength="3" Skin="WebBlue"   >
 <WebServiceSettings Method="GetUserList" Path="~/Services/WebService.asmx"></WebServiceSettings>
</telerik:RadComboBox>

在我的页面中.cs

radCmbOwnerList.Enabled = false;

我做一个回帖.

然后在 MyPage.cs 中,radCmbOwnerList.SelectedValue 等于 " 或 string.empty

试试这个。 根据您的代码解释,我认为对 Web 服务的调用没有发生,并且页面加载中未加载下拉列表。下面是示例

      ----- aspx page ----
<Telerik:RadComboBox runat="server" ID="rad"
                 AutoPostBack="true" >
                <WebServiceSettings Method="HelloWorld" 
                    Path="WebService.asmx"  />
            </Telerik:RadComboBox>
            <asp:Button runat="server" ID="btn" Text="Click"  />
------- WebService code ---
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections
Imports System.Collections.Generic
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService1
    Inherits System.Web.Services.WebService
    <WebMethod()> _
    Public Function HelloWorld() As List(Of test)
        Dim lst As New List(Of test)
        For i As Int16 = 0 To 10
            lst.Add(New test With {.text = "text" & i, .val = "val" & i})
        Next
        Return lst
    End Function
End Class
Public Class test
    Property text As String 
    Property val As String 
End Class
      ----- code behind page ----
Imports System
Imports Telerik.Web.UI
Imports System.Web
Imports System.Web.Services
Imports WebService1
Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim ws As New WebService1
            rad.DataSource = ws.HelloWorld
            rad.DataTextField = "text"
            rad.DataValueField = "val"
            rad.DataBind()
        End If
    End Sub
    Protected Sub rad_SelectedIndexChanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs) Handles rad.SelectedIndexChanged
    End Sub
    Protected Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
        rad.Enabled = False
    End Sub
    <WebMethod()> _
    Public Shared Function isDuplicate() As String
        Return "Hello text"
    End Function
End Class

相关内容

  • 没有找到相关文章

最新更新