Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用onserverClick发送参数_C#_Asp.net - Fatal编程技术网

C# 使用onserverClick发送参数

C# 使用onserverClick发送参数,c#,asp.net,C#,Asp.net,如何使用onserverclick事件发送参数 这是我的密码: <a href="javascript:void(0)" ID="platformHyperLink" runat="server" class="platformElementHL" onserverclick='<%# platformHyperLink_Click("+Eval("PLATFORM_ID").ToString()+")"%>' />click</a> 服务器代码: p

如何使用onserverclick事件发送参数

这是我的密码:

<a href="javascript:void(0)"  ID="platformHyperLink" runat="server" class="platformElementHL" onserverclick='<%# platformHyperLink_Click("+Eval("PLATFORM_ID").ToString()+")"%>' />click</a>

服务器代码:

protected void platformHyperLink_Click(object sender, EventArgs e)
{
    findDevice.Visible = true;
    LinkButton lk = sender as LinkButton;

    ClearAndHide(false);
    findDevice.Visible = true;
    DeviceSelectedValueHiddenField.Value = null;
    ModelSelectedValueHiddenField.Value = null;
    OsSelectedValueHiddenField.Value = null;

    Label PlatformNameLabel = lk.NamingContainer.FindControl("PlatformNameLabel") as Label;
    platformName = PlatformNameLabel.Text;
    SelectYourDeviceLabel.Visible = true;
    platformID = Convert.ToInt32(lk.CommandArgument.ToString());
    DataTable DT = WebsiteDataHelper.GetPlatformDevice(platformID);

    if (DT.Rows.Count == 0)
    {
        DeviceListBox.Visible = false;
       // DeviceNoDataFound.Visible = true;
        SelectYourDeviceLabel.Visible = false;

    }
    else
    {
        SelectYourDeviceLabel.Visible = true;
        DeviceListBox.Visible = true;
       // DeviceNoDataFound.Visible = false;
        for (int i = 0; i < DT.Rows.Count; i++)
        {
            string text = DT.Rows[i]["DEVICE_NAME"].ToString();
            string val = DT.Rows[i]["DEVICE_ID"].ToString();
            RadListBoxItem item = new RadListBoxItem(text, val);
            DeviceListBox.Items.Add(item);
        }

    }

}
protectedvoid platformHyperLink\u单击(对象发送者,事件参数e)
{
findDevice.Visible=true;
LinkButton lk=发送方为LinkButton;
ClearAndHide(假);
findDevice.Visible=true;
DeviceSelectedValueHiddenField.Value=null;
ModelSelectedValueHiddenField.Value=null;
OsSelectedValueHiddenField.Value=null;
标签PlatformNameLabel=lk.NamingContainer.FindControl(“PlatformNameLabel”)作为标签;
platformName=PlatformNameLabel.Text;
选择设备标签。可见=真;
platformID=Convert.ToInt32(lk.CommandArgument.ToString());
DataTable DT=WebsiteDataHelper.GetPlatformDevice(platformID);
如果(DT.Rows.Count==0)
{
DeviceListBox.Visible=false;
//DeviceNoDataFound.Visible=true;
选择设备标签。可见=假;
}
其他的
{
选择设备标签。可见=真;
DeviceListBox.Visible=true;
//DeviceNoDataFound.Visible=false;
对于(int i=0;i

问题是我无法访问platformHyperlink,我不知道为什么请帮助我调用服务器端方法而不发帖,您需要使用Ajax

您可以查看UpdatePanel或PageMethods

我想你要找的是页面方法

这应该让你开始

[ScriptMethod, WebMethod]
public static string GetLabelText()
{
    return "Hello";
}

<script type="text/javascript">    
      function InsertLabelData() {    
          PageMethods.GetLabelText(onSuccess, onFailure);    
      }   

      function onSuccess(result) {    
          var lbl = document.getElementById('lbl');    
          lbl.innerHTML = result;    
      }

      function onFailure(error) {    
          alert(error);    
      }    
      InsertLabelData();    
    </script>
[ScriptMethod,WebMethod]
公共静态字符串GetLabelText()
{
回复“你好”;
}
函数InsertLabelData(){
GetLabelText(onSuccess,onFailure);
}   
函数onSuccess(result){
var lbl=document.getElementById('lbl');
lbl.innerHTML=结果;
}
函数onFailure(错误){
警报(错误);
}    
InsertLabelData();

为什么您不使用
asp:link按钮?
?bcs我不想让它发回页面这不是我要找的,那么您要找的是什么?我如何访问服务器端功能我想了解为什么我无法访问itA服务器端功能在服务器上可用。您需要向服务器发送请求以执行它。浏览器不处理服务器端代码。我明白这就是为什么我在服务器上使用Click事件