菜菜的一问:imagebutton事件问题

yfhfh 2004-09-10 01:46:53
我在aspx上放一个imagebutton,双击imagebutton后写入到数据库读取字段绑定到TextBox1.Text的代码
运行后,为什么我按第一下imagebutton没反应,按第2下imagebutton,才会有信息在TextBox1.Text上显示出来,请各位大吓帮忙....
...全文
323 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
fxf66 2004-09-13
  • 打赏
  • 举报
回复
能不能debug啊
yfhfh 2004-09-13
  • 打赏
  • 举报
回复
<form id="form1" runat="server">
<TABLE cellSpacing="0" cellPadding="0" width="777" align="center" border="0">
<TR>
<TD width="595"><IMG src="images/qtop5.jpg" width="595" border="0"></TD>
<TD class="text" vAlign="bottom" noWrap width="178"><IMG height="11" src="images/dot.gif" width="12" border="0">
<A onclick="this.style.behavior='url(#default#homepage)';this.setHomePage ('http://192.168.0.108/index.aspx');" href="#">
设为首页</A> <IMG height="11" src="images/dot.gif" width="12" border="0"> <A onclick="window.external.addFavorite('http://192.168.0.108/index.aspx','');return(false)" href="#">
收藏本站</A></TD>
</TR>
</TABLE>
<TABLE cellSpacing="0" cellPadding="0" width="777" align="center" border="0">
<TR>
<TD width="748" background="images/qback.gif" height="36">
<TABLE cellSpacing="0" cellPadding="0" align="center" border="0">
<TR>
<TD width="10"><BR>
</TD>
<TD><IMG height="22" src="images/butleft.gif" width="21" border="0"></TD>
<TD class="nav" background="images/butback.gif"><!--prefix-linkaddr1--><A href="index.aspx"><!--postfix-linkaddr1--> <!--prefix-linkname1--><font color="#ffffff">站点首页</font><!--postfix-linkname1--></A></TD>
<TD><IMG height="22" src="images/butright.gif" width="8" border="0"></TD>
<TD width="1"><BR>
</TD>
<TD><IMG height="22" src="images/butleft.gif" width="21" border="0"></TD>
<TD class="nav" noWrap background="images/butback.gif"><!--prefix-linkaddr2--><A href="bdcx.aspx"><!--postfix-linkaddr2--> <!--prefix-linkname2--><font color="#ffffff">已报道查询</font><!--postfix-linkname2--></A></TD>
<TD><IMG height="22" src="images/butright.gif" width="8" border="0"></TD>
<TD width="1"><BR>
</TD>
<TD><IMG height="22" src="images/butleft.gif" width="21" border="0"></TD>
<TD class="nav" noWrap background="images/butback.gif"><!--prefix-linkaddr3--><A href="wbdcx.aspx"><!--postfix-linkaddr3--> <!--prefix-linkname3--><font color="#ffffff">未报道查询</font><!--postfix-linkname3--></A></TD>
<TD><IMG height="22" src="images/butright.gif" width="8" border="0"></TD>
<TD width="1"><BR>
</TD>
<TD><IMG height="22" src="images/butleft.gif" width="21" border="0"></TD>
<TD class="nav" noWrap background="images/butback.gif"><!--prefix-linkaddr4--><A href="bdtj.aspx"><!--postfix-linkaddr4--> <!--prefix-linkname4--><font color="#ffffff">报道统计</font><!--postfix-linkname4--></A></TD>
<TD><IMG height="22" src="images/butright.gif" width="8" border="0"></TD>
<TD width="1"><BR>
</TD>
<TD><IMG height="22" src="images/butleft.gif" width="21" border="0"></TD>
<TD class="nav" noWrap background="images/butback.gif"><!--prefix-linkaddr5--><A href="grcx.aspx"><!--postfix-linkaddr5--> <!--prefix-linkname5--><font color="#ffffff">个人查询</font><!--postfix-linkname5--></A></TD>
<TD><IMG height="22" src="images/butright.gif" width="8" border="0"></TD>
<TD width="1"><BR>
</TD>
<TD width="1"><BR>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<TABLE id="Table1" height="38" cellSpacing="1" cellPadding="1" width="777" align="center" border="0">
<TR>
<TD width="209"><IMG height="36" alt="" src="images/grcx1.gif" width="207"></TD>
<TD><asp:dropdownlist id="dd" runat="server" ForeColor="Black" Font-Size="Small" Width="146px" Height="19px" AutoPostBack="True">
<asp:ListItem Value="报到证号">按 报到证号</asp:ListItem>
<asp:ListItem Value="准考证号">按 准考证号</asp:ListItem>
<asp:ListItem Value="学号">按 学号</asp:ListItem>
</asp:dropdownlist><asp:label id="Label1" runat="server" Font-Size="Small">请输入 报到证号:</asp:label><asp:textbox id="TextBox1" runat="server" ForeColor="Black" Font-Size="Medium" Width="143px" Height="22px" AutoPostBack="True"></asp:textbox><asp:imagebutton id="ImageButton1" runat="server" Width="73px" Height="29px" ImageUrl="images/grxxcx.gif"></asp:imagebutton></TD>
</TR>
</TABLE>
<HR width="777" SIZE="1">
<TABLE id="Table2" height="344" cellSpacing="1" cellPadding="1" width="777" align="center" border="0">
<TR>
<TD align="middle" height="30">
<P><asp:image id="Image1" runat="server" ImageUrl="images/grxx.gif"></asp:image><BR>
<TABLE id="Table3" height="305" cellSpacing="1" cellPadding="1" width="541" border="9">
<TR vAlign="top">
<TD align="middle">
<TABLE id="Table7" height="142" cellSpacing="1" cellPadding="1" width="400" align="center" border="0">
<TR>
<TD width="103"><asp:image id="Image2" runat="server" Width="104px" Height="130px" ImageUrl="images/xszp.jpg" Visible="False"></asp:image></TD>
<TD><asp:panel id="Panel1" runat="server" Width="282px" Height="132px">
<asp:Image id="Image3" runat="server" ImageUrl="images/xm.gif"></asp:Image>
<asp:TextBox id="TextBox2" runat="server" ForeColor="#0000C0" Font-Size="Small" Width="170px" Height="22px" ReadOnly="True"></asp:TextBox>
<asp:Image id="Image4" runat="server" ImageUrl="images/bdh.gif"></asp:Image>
<asp:TextBox id="TextBox3" runat="server" ForeColor="#0000C0" Font-Size="Small" Width="170px" Height="22px" ReadOnly="True"></asp:TextBox>
<asp:Image id="Image5" runat="server" ImageUrl="images/xy.gif"></asp:Image>
<asp:TextBox id="TextBox4" runat="server" ForeColor="#0000C0" Font-Size="Small" Width="170px" Height="22px" ReadOnly="True"></asp:TextBox>
<asp:Image id="Image6" runat="server" ImageUrl="images/zy.gif"></asp:Image>
<asp:TextBox id="TextBox5" runat="server" ForeColor="#0000C0" Font-Size="Small" Width="170px" Height="22px" ReadOnly="True"></asp:TextBox>
</asp:panel></TD>
</TR>
</TABLE>
<TABLE id="Table8" height="107" cellSpacing="1" cellPadding="1" width="497" align="center" border="0">
<TR>
<TD><asp:image id="Image7" runat="server" ImageUrl="images/bj.gif"></asp:image><asp:textbox id="TextBox6" runat="server" ForeColor="#0000C0" Font-Size="Small" Width="132px" Height="22px" ReadOnly="True"></asp:textbox></TD>
<TD><asp:image id="Image8" runat="server" ImageUrl="images/xh.gif"></asp:image><asp:textbox id="TextBox7" runat="server" ForeColor="#0000C0" Font-Size="Small" Width="132px" Height="22px" ReadOnly="True"></asp:textbox></TD>
</TR>
<TR>
<TD><asp:image id="Image9" runat="server" ImageUrl="images/qs.gif"></asp:image><asp:textbox id="TextBox8" runat="server" ForeColor="#0000C0" Font-Size="Small" Width="132px" Height="22px" ReadOnly="True"></asp:textbox></TD>
<TD><asp:image id="Image11" runat="server" ImageUrl="images/dh.gif"></asp:image><asp:textbox id="TextBox9" runat="server" ForeColor="#0000C0" Font-Size="Small" Width="132px" Height="22px" ReadOnly="True"></asp:textbox></TD>
</TR>
</TABLE>
<asp:image id="Image10" runat="server" Visible="False"></asp:image></TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
</form>
yt_net 2004-09-12
  • 打赏
  • 举报
回复
把html代码贴出来
yfhfh 2004-09-12
  • 打赏
  • 举报
回复
没其他的了
as12a 2004-09-10
  • 打赏
  • 举报
回复
把其它的代码贴出来看看
yfhfh 2004-09-10
  • 打赏
  • 举报
回复
我是先用dropdownlist选择要查询的条件字段:xh or zkzh or bdzh;
然后输入字段相对应的数据,再按一下imagebutton,实现把取出来的数据绑定到TextBox1.Text
功能是实现了,就是为什么imagebutton要按2次.
as12a 2004-09-10
  • 打赏
  • 举报
回复
绑定dropdownlist的代码如果在
if(!IsPostBack)
{}
外面的话,可能会出问题
把绑定dropdownlist的代码放到if(!IsPostBack)里面看看
rickjelly2004 2004-09-10
  • 打赏
  • 举报
回复
if(dd.SelectedItem.Value=="学号")
{
pageload中是不是改边了
as12a 2004-09-10
  • 打赏
  • 举报
回复
PageLoad里面有什么东西没有
yfhfh 2004-09-10
  • 打赏
  • 举报
回复
成立的
coffeewar 2004-09-10
  • 打赏
  • 举报
回复
PageLoad时
if(dd.SelectedItem.Value=="学号")
是否成立
yfhfh 2004-09-10
  • 打赏
  • 举报
回复
private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgse)
{

if(dd.SelectedItem.Value=="学号")
{
string sql1="select a.zkzh, a.bdbj,a.xydm,a.zydm,a.bjdm, a.xm,a.bdzh,a.xh,a.lxdh,a.bmmc,a.zymc,bjqsch.qsh from (select xsxxb.zkzh, xsxxb.bdbj,xsxxb.xydm,xsxxb.zydm,xsxxb.bjdm, xsxxb.xm,xsxxb.bdzh,xsxxb.xh,xsxxb.lxdh,bmb.bmmc,zyb.zymc from xsxxb,bmb,zyb where xsxxb.zydm=zyb.zydm and xsxxb.xydm=bmb.bmdm and xsxxb.xh='"+TextBox1.Text+"') a left join bjqsch on bjqsch.xh=a.xh";
SqlConnection conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter da1=new SqlDataAdapter(sql1,conn);
DataSet ds1=new DataSet();
conn.Open();
da1.Fill(ds1,"xsxxb1");
if (ds1.Tables["xsxxb1"].Rows.Count==0)
{
TextBox2.Text="";TextBox3.Text="";TextBox4.Text="";TextBox5.Text="";
TextBox6.Text="";TextBox7.Text="";TextBox8.Text="";TextBox9.Text="";
Image10.Visible=true;
Image10.ImageUrl="images/wu.gif";
Image2.Visible=false;

}
else
{
TextBox2.Text=ds1.Tables["xsxxb1"].Rows[0]["xm"].ToString();
TextBox3.Text=ds1.Tables["xsxxb1"].Rows[0]["bdzh"].ToString();
TextBox4.Text=ds1.Tables["xsxxb1"].Rows[0]["bmmc"].ToString();
TextBox5.Text=ds1.Tables["xsxxb1"].Rows[0]["zymc"].ToString();
TextBox6.Text=ds1.Tables["xsxxb1"].Rows[0]["bjdm"].ToString();
TextBox7.Text=ds1.Tables["xsxxb1"].Rows[0]["xh"].ToString();
TextBox8.Text=ds1.Tables["xsxxb1"].Rows[0]["qsh"].ToString();
TextBox9.Text=ds1.Tables["xsxxb1"].Rows[0]["lxdh"].ToString();
if(ds1.Tables["xsxxb1"].Rows[0]["bdbj"]==System.DBNull.Value)
{
Image10.Visible=true;
Image10.ImageUrl="images/n.gif";

}
else
{
Image10.Visible=true;
Image10.ImageUrl="images/"+ds1.Tables["xsxxb1"].Rows[0]["bdbj"].ToString()+".gif";
}

if(ds1.Tables["xsxxb1"].Rows[0]["zkzh"]==System.DBNull.Value)
{
Image2.Visible=true;
Image2.ImageUrl="images/none.jpg";}
else
{
Image2.Visible=true;
Image2.ImageUrl="xsz/z"+ds1.Tables["xsxxb1"].Rows[0]["zkzh"].ToString()+".jpg";
}
conn.Close();
}
wangdequan1024 2004-09-10
  • 打赏
  • 举报
回复
把代码贴出来,你还可以用findcontrol来查找按钮,再设置它的点击事件。
rickjelly2004 2004-09-10
  • 打赏
  • 举报
回复
代码??看看呢??

62,025

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧