Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Venkatesh.Bhupathi #1
Image control not working
I have a user control inside a aspx page and i have event handler inside the
user control for the ImageClick EVent. But when i am trying to instantiate
the event in the .aspx page load event it is throwing object reference set to
null. Please find the sample code attached i have done please check the same
and let me know what mistake i am doing.
Code snippets
container.aspx
----------------
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute;
TOP: 8px" cellSpacing="1"
cellPadding="1" width="300" border="1">
<TR>
<TD></TD>
<TD></TD>
<TD>
<uc1:testCtrl id="TestCtrl1" runat="server"></uc1:testCtrl></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
</form>
Container.aspx.cs
-----
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace hollywoodclicks.members
{
/// <summary>
/// Summary description for Container.
/// </summary>
public class Container : System.Web.UI.Page
{
public testCtrl objCtrl;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
public void objCtrl_SearchTitle(object sender, ImageClickEventArgs e)
{
Response.Write("Responded to the ADD CLick");
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
(ImageClickEventHandler)objCtrl.SearchTitle+=new
ImageClickEventHandler(objCtrl_SearchTitle);
//objCtrl.SearchTitle+=new ImageClickEventHandler(SearchTitle);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
testCtrl.ascx
--------------
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="testCtrl.ascx.cs" Inherits="test.members.testCtrl"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD><INPUT id="Text1" type="text" name="Text1" runat="server"></TD>
<TD></TD>
</TR>
<TR>
<TD>
<asp:ImageButton id="ImageButton1" runat="server"
ImageUrl="../images/add.gif"></asp:ImageButton></TD>
<TD></TD>
</TR>
</TABLE>
--
Regards,
Venkatesh.Bhupathi
Venkatesh.Bhupathi Guest
-
Resize Bitmap image in image control in flex3
I am loading an image in image control initially. Then I am applying color transform to that image and want to load that bitmap image in flex3. That... -
'Edit Image' not working with Intel mac
We run a studio with various macintosh's. Our latest mac, a Quad has been set up by transferring user info from a G4. When control clicking an image... -
IO Error when working with large image PDF files
I have a 1Mb PDF file that contains a scanned image of an E size (36"x46") drawing. If I try to print this on B size (11"X17") paper there is no... -
Open Image in 'Kodak Image Edit Control' with web browser.
hi, 1.I want to show a image file of type '.tif' in the browser window; for that I'm writting as ASP code page. 2.This '.tif' type image can be... -
Including WebForm Image Control in a Webform Table Control
What is the code for including an image control in a Table control of a WebForm ???? regards -
Teemu Keiski #2
Re: Image control not working
Member name in code-behind of the Page, should match to the ID of the
control.
If your user control is:
<uc1:testCtrl id="TestCtrl1" runat="server"></uc1:testCtrl>
it's code-behind member should be
public testCtrl TestCtrl1;
I don't see the coee-behind class for the UC itself, but hopefully you have
the custom event (SearchTitle) declared there and so forth.
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Venkatesh.Bhupathi" <Venkatesh.Bhupathi @discussions.microsoft.com> wrote
in message news:A9827EC9-EC77-4A06-8805-9DFE93E312D1@microsoft.com...>I have a user control inside a aspx page and i have event handler inside
>the
> user control for the ImageClick EVent. But when i am trying to instantiate
> the event in the .aspx page load event it is throwing object reference set
> to
> null. Please find the sample code attached i have done please check the
> same
> and let me know what mistake i am doing.
>
> Code snippets
>
> container.aspx
> ----------------
> <form id="Form1" method="post" runat="server">
> <TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute;
> TOP: 8px" cellSpacing="1"
> cellPadding="1" width="300" border="1">
> <TR>
> <TD></TD>
> <TD></TD>
> <TD>
> <uc1:testCtrl id="TestCtrl1" runat="server"></uc1:testCtrl></TD>
> </TR>
> <TR>
> <TD></TD>
> <TD></TD>
> <TD></TD>
> </TR>
> <TR>
> <TD></TD>
> <TD></TD>
> <TD></TD>
> </TR>
> </TABLE>
> </form>
>
> Container.aspx.cs
> -----
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Web;
> using System.Web.SessionState;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.HtmlControls;
>
> namespace hollywoodclicks.members
> {
> /// <summary>
> /// Summary description for Container.
> /// </summary>
> public class Container : System.Web.UI.Page
> {
> public testCtrl objCtrl;
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> }
>
> public void objCtrl_SearchTitle(object sender, ImageClickEventArgs e)
> {
> Response.Write("Responded to the ADD CLick");
> }
> #region Web Form Designer generated code
> override protected void OnInit(EventArgs e)
> {
> //
> // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> //
> InitializeComponent();
> base.OnInit(e);
> }
>
> /// <summary>
> /// Required method for Designer support - do not modify
> /// the contents of this method with the code editor.
> /// </summary>
> private void InitializeComponent()
> {
> (ImageClickEventHandler)objCtrl.SearchTitle+=new
> ImageClickEventHandler(objCtrl_SearchTitle);
> //objCtrl.SearchTitle+=new ImageClickEventHandler(SearchTitle);
> this.Load += new System.EventHandler(this.Page_Load);
>
> }
> #endregion
> }
> }
>
> testCtrl.ascx
> --------------
> <%@ Control Language="c#" AutoEventWireup="false"
> Codebehind="testCtrl.ascx.cs" Inherits="test.members.testCtrl"
> TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
> <TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
> <TR>
> <TD><INPUT id="Text1" type="text" name="Text1" runat="server"></TD>
> <TD></TD>
> </TR>
> <TR>
> <TD>
> <asp:ImageButton id="ImageButton1" runat="server"
> ImageUrl="../images/add.gif"></asp:ImageButton></TD>
> <TD></TD>
> </TR>
> </TABLE>
>
> --
>
> Regards,
> Venkatesh.Bhupathi
>
>
Teemu Keiski Guest
-
Ashish Pandey #3
Image control not working
Hi,
I was reading your article and I would like to appreciate you for making it very simple and understandable. This article gives me a basic idea of Dynamically loading image in Image control in ASP.NET and it helped me a lot. I had found another nice post over the internet which also have a wonderful explanation on Dynamically loading image in Image control in ASP.NET
Thank you very much for your precious post.Ashish Pandey Guest



Reply With Quote

