Web Forms :: Composite Control Loses Subscribed Event/delegate?

Jan 18, 2010

I have created a custom composite control basically with two checkboxes. I have created a subscribable event, and the consumer has subscribes to it. But when I go to excute it, the delegate reference is null. What am I missing and why is it losing its subscribed events?

[Code]....

I am using VS2008 SP1 targeting .Net 2/3.5SP1 web site.

View 2 Replies


Similar Messages:

Web Forms :: Event Handler Not Subscribed To Content Page

Jan 6, 2011

I have a master page that contains a navigational menu, made up of nested databound repeaters. Buttons are created for the outer-most repeater's items. When the user clicks on one of these buttons, the content page loads and a label within this content page changes to reflect the text from the button that was clicked. In other words - click a button, load the page, change the label on the page to the text on the button. I have tried also changing the initialization on the content page from Page_Load to Page_PreInit to Page_Init, and nothing seems to matter as I'd like to move on in this project! Code follows:

Master Page (Site.Master):

[Code]....

Content Page (BatchView.aspx):

[Code]....

The problem is, whenever a button is clicked, it changes the title of the master page to 'Not Working', which lets me know that the TeamChosen eventhandler is null!

View 11 Replies

C# - Assign Delegate Event Handler From Dynamically Added Child Control

Apr 14, 2010

I have a control that handles commenting. In this control, I have set a delegate event handler for sending an email.

I then have various types of controls, e.g. blog, articles etc, each of which may or may not have the commenting control added (which is done dynamically with me not knowing the id's), i.e. the commenting control is added outside this control. Each of these controls handles it's emailing differently(hence the event).

What I'm trying to determine, is how to assign the event in the parent control. At the moment, I'm having to recursively search through all the controls on the page until I find the comment control, and set it that way. Example below explains:

COMMENTING CONTROL

public delegate void Commenting_OnSendEmail();
public partial class Commenting : UserControl
{
public Commenting_OnSendEmail OnComment_SendEmail();
private void Page_Load(object sender, EventArgs e)
{
if(OnComment_SendEmail != null)
{
OnComment_SendEmail();
}
}
}

PARENT CONTROL

public partial class Blog : UserControl
{
private void Page_Load(object sender, EventArgs e)
{
Commenting comControl = (Commenting)this.FindControl<Commenting>(this);
if(comControl != null)
{
comCtrol.OnComment_SendEmail += new Commenting_OnSendMail(Blog_Comment_OnSendEmail);
}
}
}

EDIT:

The reason I ask is that if I search from this.Page as the initial control, I am worried about time taken to search down the control tree to find it. Each different type of page would be different in how many control it would have. On some testing, it returns back quite quickly the result.

View 1 Replies

Custom Server Controls :: Trigger Click Event In Composite Control?

May 10, 2010

My CompositeControl creates dinamically several RadioButtonLists according to the DataSource information. These controls are added to the Controls list and rendered in CreateChildControls event.

I need to create a LinkButton that clear a specific RadioButtonList selection and do a postback, to load the DataSource information again (some selections changes the data that need to be loaded from the database). For each RadioButtonList, I've put a LinkButton and assigned the Click Event to a method inside the same CompositeControl, to do the RadioButtonList cleaning.

Unfortunatelly, the LinkButton doesn't trigger the Click Event. In HTML code, the link has the "onclick" attribute setted with the asp.net event, but when clicked, nothing happens.

View 1 Replies

Web Forms :: Event Handler In Web Part Loses Sender Value?

Jun 2, 2010

I have a web part which is going to be a part of pair of connected web parts. For simplicity, I am just describing the consumer web part.


This web part has 10 link buttons on it. And they are rendered in the Render method instead ofCreateChildControls as this webpart will be receiving values based on input from the provider web part. Each Link Button has a text which is decided dynamically based on the input from provider web part.

When I click on any of the Link Buttons, the event handler is triggered but the text on the Link Button shows up as the one set inCreateChildControls. When I trace the code, I see that the CreateChildControls gets called before the event handler (and i think that resets my Link Buttons). How do I get the event handler to show me the dynamic text instead?

Here is the code...

public class consWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{
private bool _error = false;
private LinkButton[] lkDocument = null;

[Code]....

View 3 Replies

Forms Data Controls :: Rowdatabound Event Of A Gridview Loses Its Value While Editing?

Feb 5, 2011

I have a Gridview with edit and update feature enabled. It displays the data correctly but when I click on the Edit linkbutton(to edit the data), I get the error "Object reference not set to an instance of an object".

I tried debugging and found that the row which I click (say editindex is 1) loses its value. I could identify this while debugging the code, when the code flow moves to the rowdatabound event, the label (or for that matter any control in the rowdatabound event) shows a null value and eventually errors out.

I am unable to figure out as to why the control specified in the rowdatabound event loses its value when editing. Note: The lost valueow data is the one which I tried editing.

I am attaching the code which I have written for the rowdatabound event.

[Code]....

View 6 Replies

Gridview Event, No Overload Matches Delegate

Jan 27, 2011

<asp: GridView..... ID="MyGrid" AllowSorting = "True" OnSorting = "SortMyGrid">
protected void SortMyGrid(object sender, GridViewPageEventArgs e)
DataTable TheGridData = MyGrid.DataSource as DataTable;

And then when I run the codeNo overload for 'SortMyGrid' matches delegat

View 1 Replies

C# - Adding Delegate Or Event Property To Class?

Oct 4, 2010

I created a control where other developers can create an instance and use. There is a button click in the control. How do I allow developers to plug in their own code in a certain part of my control? I am not sure if or how exactly to use a delegate or event in this scenario.

[code].....

How to I update MyControl to allow this?

View 4 Replies

Web Forms :: How To Use Delegate In User Control To Trigger Events

Mar 2, 2011

I have got a query regarding the usage of delegate in usercontrols. The scenario is I have got a user control which acts as a footer

on all the pages, It has the following place holders : Email, Print, Logout.

What I want to acheive here is when the customer logged in he/she has certain feauture's on the website for instance his/her personal diary,

dieting charts, birthday calender etc. I have figured out a way to create pdf's of each summary , what I am looking for is how to use the usercontrol

for instance when the customer clicks on the email place holder on certain page which is in the footer usercontrol, the following place holder should send

an email with the pdf file of that particular page attached to the customer. I came to know that delegate is the best way of doing it, but I cant find any specific tutorial on it.

View 3 Replies

Web Forms :: User Control Causes Double Postback When Using A Delegate?

May 14, 2010

I was able to get a user control to use a method on the parent page. The problem is, the delegate causes the page to do two postbacks. Is there a way to fix this?

View 2 Replies

Web Forms :: Assignment Of FormView Control In Design-time To User Defined Composite Control

Feb 1, 2011

i create a composite control as can be seen in code below, and add this control to webform, assign FormView1 to the HeaderControlName property, Run the page, the system will generate parse error message :
Cannot create an object of type 'System.Web.UI.WebControls.FormView' from its string representation 'FormView1' for the 'HeaderControlName' property. However, if i don't assign FormView1 in design screen and manually (through coding) assign FormView1 to the custom control on init, it works as expected.

custom control
public class CmdTest : CompositeControl
{
public virtual FormView HeaderControlName
{
get
{
object oObject = ViewState["HeaderControlName"];
return (oObject == null) ? null : (FormView)oObject;
}
set
{
ViewState["HeaderControlName"] = value;
}
}
protected override void CreateChildControls(
{
Controls.Clear();
Button xx = new Button();
Controls.Add(xx);
}
}
webpage.aspx (assign FormView1 in design time, it will generate error)
<Utils:CmdTest ID="CmdTest1" runat="server" HeaderControlName="FormView1" />
webpage.aspx (didn't assign FormView1 in ASPX, but assign it on Init Code, it works)
<Utils:CmdTest ID="CmdTest1" runat="server" oninit="CmdTest1_Init" />
Webpage.aspx.cs
protected void BsCmdTest1_Init(object sender, EventArgs e)
{
CmdTest1.HeaderControlName = FormView1;
}

View 2 Replies

Web Forms :: FileUpload Control Loses Value On Postback?

Sep 11, 2010

I'm having a little problem with my file uploading. Does anybody know how to maintain the value in the FileUpload control between server posts?

I have a form which, among other things, uploads a file. I am using an ileUpload control (created dynamically) to let a user browse their PC for a file and then using the SaveAs method to upload the file to the server.When I'm selecting a file and Click on Next button for processing then selected file is lost.

Same is happening with me with HtmlTextArea (dynamically generated) , the problem was that I was not again re-initializing the controls after postback. What I did is re-initialized it in Init method of placeholder (as I have created/placed all dynamic controls in placeholder ).

But this thing is not working for fileupload control. I found solution in one of the forum is that "use hiddenField Control to transfer the selected file from the client to server"but this mechanism will only help to retain the name of file
in a hidden variable and the FileUpload1.PostedFile.SaveAs(filename) will not work bcz of absense of object (fileupload1).

here is code:

[Code]....

I have done almost the same in different test project , it works . I dont know whats wrong?

[Code]....

How to correct this?

View 8 Replies

Repeater Databound Loses Data & Event On Postback - Is There A Best Practice Solution

Oct 7, 2010

Currently struggling with a problem that I've encountered variations on in the past. At the moment a worthwhile solution escapes me, but it seems such an obvious issue that I can't help wondering whether or not there's a "best practice" approach I should adopt.Without code, here's the issues in a nutshell:


page has databound control (a repeater) which isn't populated until user inputs data and clicks a button.Repeater item template contains a buttonUser clicks button, page posts back. On load, the repeater is actually empty so event is never handled because the originating control no longer existsGo back to the beginning of wretched cycle I've confirmed that this is the problem because if you provide the repeater with some static data on page load, everything works fine. But of course that's no use because it has to be populated dynamically.Is there a commonly approved way round this headache? I can store the data in session and re-use it on page load, but it seems terribly clumsy.

View 2 Replies

Web Forms :: Control Loses Focus After Posting Page From Javascript?

Apr 5, 2010

I try to postback my page to the server using ctrl+Enter sequence.Without UpdatePanel it works well, but it works only two times inside updatepanel and then my control loses the focus. So I have some questions:

1. Why my control loses the focus if it is located inside updatepanel?
2. What is the best way to use ctrl+Enter sequence to post the page to the server?

Here is my code:

[Code]....

View 4 Replies

ADO.NET :: Does Entity Framework 3.5 Support Composite Foreign Key/Composite Primary Key

Dec 14, 2010

Does ADO.Net Entity Framework 3.5 support Composite Foreign key/Composite primary key?

View 5 Replies

Web Forms :: Composite Control Attribute Assignment?

Mar 29, 2010

I have got a composite control and i would like to dictate which attribute/property is assigned to the control first from the markup?example in the aspx file:

<MM:MyControl ID="" runat="server" ViewType="normal" BaseType="RealBase"></MM:MyControl>

when the control gets created from the mark-up above, ViewType will be assigned first, Which is what I do not want, I would like RealBase to be assigned first under all circumstances. This control is to be users by other developers so I cannot just switch the order.

View 1 Replies

Web Forms :: Sending Email With Verification Link While User Subscribed To A Site

Sep 2, 2012

a vistor subscribes for newsletter by providing emailid.a mail should be automically sent to that email with verification link.when owner upon clicking verifcation link is confirmed to send newsletter.

View 1 Replies

Pass A Delegate In Server Control Parameter?

Jan 14, 2011

I have a server control that performs some logic. I'd love to provide a default implementation of this logic in the code of the control, but allow a developer to pass an alternate implementation of this logic in as a delegate, if they wish.

So...

<prefix:MyControl FooLogicMethod="MyUtilityClass.MyFooLogicMethod" runat="server"/>

If they don't specify this, I'll use my default method. If they do specify it, I'll use the method they passed in.

Can I do this as a delegate, or do I need to reflect it?

View 1 Replies

Forms Data Controls :: Show GridView Designer For Composite Control?

Apr 29, 2010

I'm working on building a an ASP.NET composite control that is a wrapper for a GridView object. I have been able to figure out how compose the control in order for the markup to appear correctly when added to an ASPX page. Now the issue I'm having is that when I drop an instance of the control on a form from the toolbox, I can't interact with the control using the functionality exposed by a GridView (e.g. columns editor, data source selector, etc.), and I don't see any design-time rendering of the child GridView control. What I would like to do is to basically forward the designer behavior of my composite control down to its child GridView control. I have experimented with implementing a custom designer class that inherits from GridViewDesigner that simply initializes itself using the GridView child of my composite control. However, this doesn't seem to work, as I encounter an "object reference not set to an instance of object" error at design time; I'm wondering if this is even the appropriate strategy to achieve what I'm looking for. how to enable GridView-like design time behavior in composite controls. I have scoured the Web looking for articles on how this is accomplished, but I've surprisingly found virtually no resources on the topic.

View 6 Replies

AJAX :: Creating New Composite Control To Make A Full Calendar Control?

Jan 11, 2011

i create new composite control to make a full calendar control.

[Code]....

All is good until i put

[Code]....

View 2 Replies

Custom Server Controls :: To Include Rating Control In A Composite Control?

Feb 12, 2010

I am trying to included a rating control in a composite control that renders many different type of controls. I render the controls by overriding the rendercontents so that I can control the layout of the controls. When I try to add the rating control to the output i get a Page cannot be null error. Can someone provide me with the proper way to render a rating control from a composite control and be able to control the layout of the child controls.

View 3 Replies

AJAX :: Error When Rendering A Rating Control In A Composite Control?

Feb 11, 2010

I have a custom control that renders different controls based on a property value. This all works correctly until i try and add a rating control to the control. When i render both controls in the CreateChildControls the control is rendered properly.

However when i try to add layout by overriding the RenderContents method and rendering controls there, an error is generated
Extender controls may not be registered after PreRender.The code shows both methods of creating the controls.

[Code]....

View 2 Replies

Forms Data Controls :: Databinding Composite Control Properties Inside A Repeater?

Jul 14, 2010

I have a composite control inside a repeater. I am trying to set the controls public properties inline like so (this is a simplified example):

<uc1:Control runat="server" ID="id" Value='<%# Eval("value") %>'>

When I place the repeater inside a user control INSIDE ANOTHER user control and onto the page this works - the property is correctly set, if I inspect it inside the EnsureChildControls() method of the custom control the composite control's Value propertyis set to Eval("value") as intended.

View 2 Replies

Registering A Composite Control?

Dec 13, 2010

I am learning custom controls and just finished my first one. The problem is that I am struggling to register it in my web config and have the compiler recognize it. Right now this results in a YSOD about the reference to the control.

note: exact error - Error Unknown server tag 'cc:LblTextBox'.

Web Config

//..
//..
<pages>
<controls>
<add tagPrefix="cc" namespace="Controls.Server"/>
</controls>
</pages>
</system.web>
The control code-behind
namespace Controls.Server
{
public class LblTextBox : CompositeControl
{
//...
}
}
mark-up
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ControlsMain.aspx.cs" Inherits="Pages_ControlsMain" Trace="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Controls Area</title>
</head>
<body>
<form id="form1" runat="server">
<div>
First attempt at a simple composite control <br />
<cc:LblTextBox ID="ccLblTbHybrid" runat="server" LabelText="Name:" />
</div>
</form>
</body>

View 2 Replies

How To Convert A User Control To Web/Composite Control

Feb 10, 2010

Is there a simple process to convert an user control to a web/composite control?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved