简体   繁体   English

如何从后面的代码中调用.aspx页中的书面函数

[英]how to call a written function in .aspx page from code behind

i have an asp:DropDownList and i want to disable it in some condition.it can happen with a function in aspx page.but from code behind (after some c# work) it wont! 我有一个asp:DropDownList,我想在某种情况下禁用它。它可能会在aspx page。功能中发生,但是从后面的代码(经过一些C#工作)之后就不会了!

this is the element: 这是元素:

ASPX: ASPX:

<asp:DropDownList ClientIDMode="Static" ID="cmbState" runat="server" Width="130px" Height="30px" Font-Size="Small" Font-Bold="true" DataValueField="StateID" DataTextField="Name" AutoPostBack="True"></asp:DropDownList>

Code-Behind: 代码隐藏:

bool condition = true;
if (condition == true)
{
    cmbState.Enabled = false;
}

This should work unless you have something in your Page_Load method which would counter it. 除非您在Page_Load方法中有可以解决该问题的方法,否则此方法应该起作用。
The AutoPostBack property is important due to the order in which events are carried out on the page. 由于页面上事件的执行顺序,因此AutoPostBack属性很重要。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从部分加载的ASPX页面的代码背后调用javascript函数 - How to call a javascript function from code-behind of a partially loaded aspx page 从aspx中的javascript调用函数背后的代码 - Call a code behind function from javascript in aspx 从文件后面的ASCII代码调用Aspx Java脚本函数 - Call Aspx java script function from ascx code behind file 如何调用Web Forms代码后面C#方法from.aspx页面javascript - How to call in Web Forms code behind C# method from .aspx page javascript 在背后的代码中通过函数调用传递客户端ID时,无法通过aspx页面上的javascript函数访问字段的值(页面加载) - Unable to access a field's value via javascript function on aspx page on passing client id from function call in code behind(page load) 如何从页面后面的代码中调用js文件功能 - How to call js file function from code behind page 如何在后面的代码中访问另一个ASPX页面? - How can I reach an aspx page from another in code behind? 在按钮上,单击发送Ajax调用并从aspx.cs(后面的代码)获取值到aspx页面,并将其显示在同一页面的输入字段中 - On button click send Ajax call and get value from aspx.cs(code behind) to aspx page and display it in input field in the same page 从后面的vb.net代码调用外部javascript函数中定义的函数(.html而不是.aspx) - Call a function defined in an external javascript function from vb.net code behind (.html not .aspx) 如何从代码后面调用这个javascript函数 - How to call this javascript function from code behind
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM