|
-
Oct 25th, 2005, 04:36 AM
#1
Thread Starter
Member
Imagebutton in a usercontrol
Hi!
I have added a imagebutton on to a usercontrol. Here is the formcode
HTML Code:
<div style="WIDTH: 1000px; HEIGHT: 55px">
<table cellSpacing="3" cellPadding="3" width="1000" border="0">
<!--DWLayoutTable-->
<tr>
<td vAlign="top" width="24" height="24"><IMG height="24" alt="Ny kontakt" src="Images/Ikoner/ny.gif" width="24"></td>
<td vAlign="top" width="24"><a href="frmListContact.aspx"><IMG src="Images/Ikoner/Lista.gif" alt="Lista" width="24" height="24" border="0"></a></td>
<td vAlign="top" width="24">
<asp:ImageButton id="imgbSave" runat="server" ImageUrl="Images/Ikoner/Spara.gif"></asp:ImageButton></td>
<td vAlign="top" width="24"><IMG height="24" alt="Ta bort" src="Images/Ikoner/radera.gif" width="24"></td>
<td class="text" align="right" width="844"> </td>
</tr>
<TR>
<TD vAlign="top" bgColor="#000000" colSpan="5" height="1"></TD>
</TR>
<TR>
<TD vAlign="top" bgColor="#ffffff" colSpan="5" height="1"><img src="Images/Ikoner/kundkort.gif" width="32" height="32" align="absMiddle">
<strong class="text style1">KUNDKORT</strong></TD>
</TR>
</table>
</div>
Here is the codebehind code
VB Code:
Public Class ContactMenu
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents imgbSave As System.Web.UI.WebControls.ImageButton
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Public Sub imgbSave_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgbSave.Click
Dim obj As Contactcard = New Contactcard
Dim I As Integer = obj.Save_Contact()
If I = 1 Then
End If
End Sub
End Class
My problems is that the imgbSave_Click metod is not executed when i press the imagebutton.
What´s wrong?
/Tyson
-
Oct 25th, 2005, 08:45 AM
#2
Re: Imagebutton in a usercontrol
Do you have form tags on your page, which is set to runat="server"?
-
Oct 25th, 2005, 09:30 AM
#3
Addicted Member
Re: Imagebutton in a usercontrol
Are you loading the usercontrol in your form on every postback? You need to do this to run the usercontrol's events.
-
Oct 25th, 2005, 09:45 AM
#4
Thread Starter
Member
Re: Imagebutton in a usercontrol
Yes I have formtags.
Here is the code from the form that loads the usercontrol
HTML Code:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="frmContact.aspx.vb" Inherits="MW.frmContact"%>
<%@ Register TagPrefix="SC" TagName="ContactCard" Src="Contactcard.ascx" %>
<%@ Register TagPrefix="SC" TagName="ContactMenu" Src="ContactMenu.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Kontaktkort</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="Body.css" type="text/css" rel="stylesheet">
<style type="text/css">.style1 { FONT-SIZE: 14px; COLOR: #ffffff }
</style>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table borderColor="#ece9d8" width="1000">
<!--DWLayoutTable-->
<tr bgColor="#000000">
<TD vAlign="top" colSpan="3" height="1"></TD>
</tr>
<tr vAlign="middle" bgColor="#006699">
<TD class="text" style="HEIGHT: 34px" width="660" height="34"><!--DWLayoutEmptyCell-->
<STRONG><FONT color="#ffffff" size="3">WebToMamut</FONT></STRONG></TD>
<TD class="text" style="HEIGHT: 34px" width="164"><!--DWLayoutEmptyCell--> <FONT color="#ffffff">Inloggad:</FONT></TD>
<TD width="151" class="text" style="HEIGHT: 34px" align="center"><!--DWLayoutEmptyCell--><asp:label id="Label1" runat="server" Font-Names="Verdana" Font-Size="8pt" ForeColor="White">Label</asp:label> </TD>
</tr>
<tr bgColor="#000000">
<TD vAlign="top" colSpan="3" height="1"></TD>
</tr>
</TR>
<tr>
<TD vAlign="top" colSpan="3"><SC:CONTACTMENU id="Contactcard1" runat="server"></SC:CONTACTMENU></TD>
</tr>
</TR>
<tr>
<TD vAlign="top" colSpan="3"><SC:CONTACTCARD id="Contact" runat="server"></SC:CONTACTCARD></TD>
</tr>
</table>
<BR>
</form>
</body>
</HTML>
so i guess that i load the usercontrol everytime.
/tyson
-
Oct 25th, 2005, 09:51 AM
#5
Re: Imagebutton in a usercontrol
Try this: Set AutoEventWireup="true" in the page directive.
-
Oct 25th, 2005, 10:40 AM
#6
Thread Starter
Member
Re: Imagebutton in a usercontrol
I tried that and the page did load twice but no effect.
You see! when i press the imagebutton the page that holds the usercontrol is reloaded. I added a breakpoint att the postback event. and the code steps over the ispostback because its true. then the page stops.
dose this have something to do that the form how is holding the imagebutton is a user control?
/Tyson
-
Oct 25th, 2005, 12:44 PM
#7
Re: Imagebutton in a usercontrol
OK, I thought your page wasn't posting back either. Set autoeventwireup back to false, and place a breakpoint at the image button's click event, and follow it from there. What happens?
-
Oct 25th, 2005, 04:16 PM
#8
Thread Starter
Member
Re: Imagebutton in a usercontrol
 Originally Posted by mendhak
OK, I thought your page wasn't posting back either. Set autoeventwireup back to false, and place a breakpoint at the image button's click event, and follow it from there. What happens?
i did that and nothing happends. I placed a breakpoint on the Image_click event and also at the page_load on the mainform. Al thats happend was that the code just step over the ispostback = false code in the mani form and stoped. It didn´t go to the Image button click eventet.
/Tyson
-
Oct 31st, 2005, 04:18 AM
#9
Thread Starter
Member
Re: Imagebutton in a usercontrol
I must be doing something wrong here, any ideas
/tyson
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|