js 服务器端控件赋值

<%@ Import Namespace="System.Data" %>

<asp:HiddenField ID="hfOrdinaryType" runat="server" />

 

<script type="text/javascript">

function onClickReg()

{

  document.getElementById("<%=hfOrdinaryType.ClientID%>").value=type.toString();

}
</script>

 

 

<!--ajax-->

web.config

<httpHandlers>

        <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>
</httpHandlers>

<script type="text/javascript">

function onClickReg()

{

  Soft_NewGroup.SetHfType(1,type);

}
</script>

public partial class Soft_NewGroup : WebBasePage
{

protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            //注册Ajax类型
            Ajax.Utility.RegisterTypeForAjax(typeof(Soft_NewGroup));
        }
 
    }

[Ajax.AjaxMethod()]
    public void SetHfType(int id,int iType)
    {
        if (id == 1)
            hfOrdinaryType.Value = iType.ToString();
        else if (id == 2)
            hfSpontaneousType.Value = iType.ToString();
        else
            hfFixedType.Value = iType.ToString();
    }

}

posted @ 2010-06-11 16:24  小さいです哥  阅读(476)  评论(0编辑  收藏  举报