我将一些自制的Web用户控件放在一个单独的Project"WebControls"中,现在想要从另一个Project中重用它们
我的控制包括:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestControl.ascx.cs" Inherits="WebControls.TestControl" %>
<asp:Label ID="lblTest" runat="server" ></asp:Label>
<asp:TextBox ID="textBox" runat="server" Width="" />
<asp:HiddenField ID="hiddenFieldId" runat="server" />
Run Code Online (Sandbox Code Playgroud)
代码背后:
namespace WebControls
{
public partial class TestControl : System.Web.UI.UserControl
{
public Unit Width
{
get { return textBox.Width; }
set { textBox.Width = value; }
}
public string SelectedId
{
get { return hiddenFieldId.Value; }
set { hiddenFieldId.Value = value; }
}
public string SelectedText
{
get { return textBox.Text; }
set { textBox.Text = value;}
} …Run Code Online (Sandbox Code Playgroud) 我开始一个过程
Process app = new Process();
app.StartInfo.UseShellExecute = false;
app.StartInfo.FileName = path;
app.StartInfo.Domain = "Domain";
app.StartInfo.UserName = "userName";
string password = "Password";
System.Security.SecureString ssPwd = new System.Security.SecureString();
for (int x = 0; x < password.Length; x++)
{
ssPwd.AppendChar(password[x]);
}
password = "";
app.StartInfo.Password = ssPwd;
app.Start();
Run Code Online (Sandbox Code Playgroud)
然后我确认它正在运行:
private bool IsRunning(string name)
{
Process[] processlist = Process.GetProcesses();
if (Process.GetProcessesByName(name).Length > 0)
{
string user = Process.GetProcessesByName(name)[0].StartInfo.UserName;
log.Debug("Process " + name + " is running by : " + user);
return true; …Run Code Online (Sandbox Code Playgroud) 谁能向我解释一下?
CheckBox ckRequest = new CheckBox();
ckRequest.ID = "ckRequest";
ckRequest.DataBinding += new EventHandler(this.CkIsRequested_DataBinding);
container.Controls.Add(ckRequest);
Control con = container.FindControl("ckRequest");
Run Code Online (Sandbox Code Playgroud)
调试显示 con 仍然为空。
调试还向我展示了,conteiner.Controls 有一个 ID 为“ckRequest”的项目
怎么会这样????
非常感谢您的回答。
其实我尝试以下。 findcontrol 没有在 rowUpdating 事件处理程序中找到动态创建的控件 这对我来说很有意义, findcontrol 仅适用于创建的页面。
页面的可视化树是在哪个时间点创建的?