if (listBox1.SelectedIndex != -1) { if (listBox1.Items[listBox1.SelectedIndex].ToString() == "值") { Form3 f = new Form3(); f.ShowDialog(); } else { MessageBox.Show("请选择别的项!"); } }
if (listBox1.SelectedIndex != -1) { if (listBox1.Items[listBox1.SelectedIndex].ToString() == "值") { Form3 f = new Form3(); f.ShowDialog(); } else { MessageBox.Show("请选择别的项!"); } } 这样写不对啊,有错误... 再详细说明一下问题:一个listbox中绑定服务器数据库上的七项 我想点击其中第4项到A.aspx文件 点击别的项提示"请点击井筒项"
if (listBox1.SelectedIndex==3) { if (listBox1.Items[listBox1.SelectedIndex].ToString() == "值") { Form3 f = new Form3(); f.ShowDialog(); } else { MessageBox.Show("请选择别的项!"); } }
{
if (listBox1.Items[listBox1.SelectedIndex].ToString() == "值")
{
Form3 f = new Form3();
f.ShowDialog();
}
else
{
MessageBox.Show("请选择别的项!");
}
}
{
if (listBox1.Items[listBox1.SelectedIndex].ToString() == "值")
{
Form3 f = new Form3();
f.ShowDialog();
}
else
{
MessageBox.Show("请选择别的项!");
}
}
这样写不对啊,有错误...
再详细说明一下问题:一个listbox中绑定服务器数据库上的七项
我想点击其中第4项到A.aspx文件
点击别的项提示"请点击井筒项"
{
if (listBox1.Items[listBox1.SelectedIndex].ToString() == "值")
{
Form3 f = new Form3();
f.ShowDialog();
}
else
{
MessageBox.Show("请选择别的项!");
}
}
我想点击其中第4项到A.aspx页面
点击别的项提示"请点击井筒项"
我知道在这写.可是俺不会写,555555
{
if (listBox1.SelectedIndex==4)
{
request.redirect("a.aspx");
}
else
{
MessageBox.Show("请选择别的项!");
}
} 你最好写在javascript里面
{
if (this.ListBox1.SelectedIndex == 4)
{
Response.Redirect("CD_WELL_SOURCE.aspx");
}
else
............................我这样写的,可是点击第四项根本不管事,没反应...5555555
MessageBox.Show("请选择别的项!");这样写有如下错误当前上下文中不存在名称“MessageBox”不能弹出.咋回事呢
{
if (this.ListBox1.SelectedIndex == 4)
{
Response.Redirect("CD_WELL_SOURCE.aspx");
}
else
{
Response.Write("<script>alert('请选择Wellbore')</script>"); }
}
这样写的结果是默认选中是第5项就会到CD_WELL_SOURCE.aspx页面
如果不是,那就弹出对话框.我要的不是这样的.我要的是点击第第5项就会到CD_WELL_SOURCE.aspx页面
如果不是,那就弹出对话框.请哪位高人指点
如果默认不是第5项,那就弹出对话框. 我要的不是这样的. 我要的是点击第5项就会到CD_WELL_SOURCE.aspx页面
如果点击别的,那就弹出对话框. 麻烦请教,谢谢
这样弹
应该在selectedindexchange事件里写
{
if (this.ListBox1.SelectedIndex != -1)
{
if (this.ListBox1.SelectedIndex == 3)
{
Response.Redirect("CD_WELL_SOURCE.aspx");
}
else
{
Response.Write("<script>alert('你好,请选择Wellbore')</script>");
}
}
}
就是这样写的.出来结果不对.我要的是点击第5项就会到CD_WELL_SOURCE.aspx页面
如果点击别的,那就弹出对话框.
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True"
onselectedindexchanged="ListBox1_SelectedIndexChanged">
</asp:ListBox>
后台代码
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.ListBox1.SelectedIndex != -1)
{
if (this.ListBox1.SelectedIndex == 4)
{
Response.Redirect("CD_WELL_SOURCE.aspx");
}
else
{
Response.Write(" <script>alert('请选择Wellbore') </script>"); }
}
}
加个 ;^o^
如果默认不是第5项,那就弹出对话框. 我要的不是这样的. 我要的是点击第5项就会到CD_WELL_SOURCE.aspx页面
如果点击别项,那就弹出对话框.
但是我想要的是点击这一顶能进那个页面,点击别的弹出对话框
{
if (this.ListBox1.SelectedIndex == 4)
{
Response.Redirect("A.aspx");
}
else
{
Response.Write("<script>alert('请选择其他项'); </script>"); }
}
from1事件代码:
string str ;
str=ListBox1选择项的值
form2 ff=new form(str);
ff.show();
form2代码,也就是重写form2的构造函数:
public form2(string ss)
{
InitializeComponent();
tbcantai.Text = ss;
}
这样就可以将form1中要传的值传给form2中接受值的控件,我想在web程序中也是这个思路吧!
很简单