关于c#填写表单,怎么去设置下拉框的值(自己去设值,不用网页的值)比如有个网页下拉框有 OPTION 男  OPTION 女我自己去设置的填写 中性人该怎么设置?
   

解决方案 »

  1.   

    把下拉框设置成服务器控件就可以在后台加了,就是加上runat="server"
      

  2.   

    那你完全可以自己在加一个选择项 或者利用 JS 动态加载,不太明白究竟要干嘛
    $("<option value='" + this.ID + "'>" + this.Name + "</option>").appendTo("#Up_ID");
      

  3.   

    是这样的  我本来想直接POST的  这样不用选择下拉框里面的值了 但是程序必须用填写表单的方式  必须另外去给下拉框的值。这网页是不是我写的 我制作C/S程序 另外我也不能修改服务器的文件的 
      

  4.   


    <asp:DropDownList ID="U_Status" runat="server">
                        <asp:ListItem Value="0">正常</asp:ListItem>
                        <asp:ListItem Value="1">禁止</asp:ListItem>
                        </asp:DropDownList>
      

  5.   

    webBrowser1.Document.GetElementById("ctnStau").SetAttribute("selectedIndex", "1");
    webBrowser1.Document.GetElementById("berth").SetAttribute("value", "hgffffhgf");
       webBrowser1.Navigate("javascript:berth.options[0].text='fdfds';void(0);");可以用本地JS修改吗?
      

  6.   

    问题是那个INPUT是不能输入的
      

  7.   

    dropdownList与TextBox结合:http://www.cnblogs.com/SoYoung/archive/2009/05/26/1490487.html
    参考VB:
    Imports System.ComponentModel
    Imports System.Web.UI
    Imports System.Web.UI.Design
    Imports System.Web.UI.WebControls'''/*
    ''' * CBDAspNet - ASP.Net Development Framework
    ''' * Copyright (C) 2004-2005 Chengdu Binary Digital Tech. Co.,Ltd.
    ''' * 
    ''' * Company Homepage
    ''' *    http://www.cbdsystem.com.cn
    ''' *
    ''' * File Name: D:\CuteProject\CBDAspNet\CBDWebControls\CBDTextBox\CBDTextBox.vb
    ''' *
    ''' * Version:  1.0
    ''' * Modified: 2005年1月27日 10:00:46
    ''' * 
    ''' * File Authors:
    ''' *      Ryan Liu ([email protected])
    ''' * Namespace CBDAspNet.WebControls.HTML    ''' <summary>
        ''' 可输入的下拉框控件
        ''' </summary>
        <ToolboxData("<{0}:TextBox runat=""server"" />")> _
        Public Class TextBox
            Inherits System.Web.UI.WebControls.TextBox        Private _values As Hashtable        Public _DropDownList As DropDownList        Public Sub New()
                _DropDownList = New DropDownList
                _values = New Hashtable
            End Sub        Public Property Values() As Hashtable
                Get
                    Return _values
                End Get
                Set(ByVal Value As Hashtable)
                    _values = Value
                End Set
            End Property        Protected Overrides Sub Render(ByVal Output As System.Web.UI.HtmlTextWriter)            Dim iWidth As Integer = MyBase.Width.Value
                If iWidth = 0 Then
                    iWidth = 102
                    'MyBase.Width = Unit.Parse("102px")
                End If            Dim sWidth As Integer = iWidth + 16
                Dim spanWidth As Integer = sWidth - 18            Output.Write("<div style=""POSITION:relative"">")
                Output.Write("<span style=""MARGIN-LEFT:" & spanWidth & "px;OVERFLOW:hidden;WIDTH:18px"">")            _DropDownList.Width = Unit.Parse(sWidth & "px")
                _DropDownList.Style.Add("MARGIN-LEFT", "-" & spanWidth & "px")
                _DropDownList.Attributes.Add("onchange", "this.parentNode.nextSibling.value=this.value")            If _values.Count > 0 Then
                    For Each key As String In _values.Keys
                        Dim item As ListItem = New ListItem
                        item.Value = key
                        item.Text = _values(key)
                        _DropDownList.Items.Add(item)
                    Next
                End If
                ''如果只有一个可选内容
                If _DropDownList.Items.Count = 1 Then
                    Dim item As ListItem = New ListItem
                    item.Value = ""
                    item.Text = " "
                    _DropDownList.Items.Add(item)
                    _DropDownList.SelectedIndex = 1
                End If
                _DropDownList.RenderControl(Output)            Output.Write("</span>")            MyBase.Style.Clear()
                MyBase.Width = Unit.Parse(iWidth & "px")
                MyBase.Style.Add("left", "0px")
                MyBase.Style.Add("POSITION", "absolute")            MyBase.Render(Output)            Output.Write("</div>")        End Sub    End ClassEnd Namespace