ASP.net事件中对控件操作不起作用,求答
CS代码:
static Process p;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
open();
}
void open()
{
p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
p.Start();
p.BeginOutputReadLine();
}
void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
TextBox1.Text += e.Data;
}
protected void Button1_Click(object sender, EventArgs e)
{
p.StandardInput.WriteLine("dir d:");
}
Html代码:
<asp:TextBox ID="TextBox1" runat="server" Height="297px" TextMode="MultiLine"
Width="506px"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
为什么我在Process进程事件void p_OutputDataReceived(object sender, DataReceivedEventArgs e)中的代码不起作用呢。好像都不会回发到客户端去。
请问这要怎么做呢。让void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
中的代码能对客户端起作用。