Set Custom UserControl Variables When Its In A Repeater?
Mar 17, 2010
<%@ Register Src="~/Controls/PressFileDownload.ascx" TagName="pfd" TagPrefix="uc1" %>
<asp:Repeater id="Repeater1" runat="Server" OnItemDataBound="RPTLayer_OnItemDataBound">
<ItemTemplate>
<asp:Label ID="LBLHeader" Runat="server" Visible="false"></asp:Label>
<asp:Image ID="IMGThumb" Runat="server" Visible="false"></asp:Image>
<asp:Label ID="LBLBody" Runat="server" class="layerBody"></asp:Label>
<uc1:pfd ID="pfd1" runat="server" ShowContainerName="false" ParentContentTypeId="55" />
<asp:Literal ID="litLayerLinks" runat="server"></asp:Literal>
</ItemTemplate>
</asp:Repeater>
System.Web.UI.WebControls.Label lbl;
System.Web.UI.WebControls.Literal lit;
System.Web.UI.WebControls.Image img;
System.Web.UI.WebControls.HyperLink hl;
System.Web.UI.UserControl uc;
I need to set the ParentItemID variable for the uc1:pdf listed inside the repeater.
I thought I should be able to find uc by looking in the e.Item and then setting it somehow. I think this is the part where I'm missing something.
uc = (UserControl)e.Item.FindControl("pfd1");
if (uc != null) { uc.Attributes["ParentItemID"] = i.ItemID.ToString(); }
Also tried this with similar results... when I debug inside my usercontrol (pfd1) the parameters I am trying to set have not been set.
uc = (UserControl)e.Item.FindControl("pfd1");
if (uc != null)
{
uc.Attributes.Add("ContainerID", _cid.ToString());
uc.Attributes.Add("ParentItemId", i.ItemID.ToString());
}
UPDATE: It looks like my controls are not connected by a namespace. I've wrapped by the parent control (Layer) and the PressFileDownlad control in a namespace "MyControls". Also updated their Inherits reference on the aspx to read "MyControls.xxxxx". I'm able to type "MyControls.Layer" inside the code on layer.aspx.cs but I'm not able to get "MyControls.PressFileDownload"
View 3 Replies
Similar Messages:
May 10, 2010
I have a code behind page with two functions that return two counts (iCount and iCount2). In my repeater table I can display the results of the functions just fine, but now I need to do some conditional logic based on the results of the functions, eg:If iCount =>3 AND iCount2 =>1 Then
View 6 Replies
Feb 23, 2011
I have an update panel on my page. Within that is a repeater which has a user control in it. Inside the user control I allow an update to the datasource of the repeater. I am able to successfully save the data to the database but when I call the .Update method of the update panel, the user control is blank. If I proceed to refresh the page, the data appears with the changes I made. why the data is disappearing when I call the .Update method?
View 1 Replies
Mar 18, 2010
I think I am not a beginner in asp.net, but now maybe I dont see the solution because it must be so easy..I have a simple Repeater on an UserControl(ascx).After a Postback on a button click I would like loop trough allthe Items from the Repeater, but the RepeaterItem-Collection is Empty!!!!!But NOW it comes, when I move the whole code from the UserControlto the Codebehind of an Page, and move the Repeater also to the Page.It works!!!! The Items-Collection are not empty after the Postback!!!Here is the simple Codebehind from the UserControl:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
[code]...
View 5 Replies
Mar 25, 2011
I have a custom membership project for my asp .net website and I want to use a few custom variables for use in the ValidateUser function, can I set these somewhere like in the OnLoggingIn method of the Login Control?
View 2 Replies
May 3, 2010
We have Novell's Access Manager protecting our site. After the user logs in, Access Manager forwards the request back to a web page. On that web page, I need to read a combination of some Basic Auth username information as well as some custom header variablest that AM is passing to the web page. AM will continue to send these variables/values on every page as long as the user stays logged in.
What I'd like to do is create a class that checks for these values to evaluate whether the user is logged in or not. How do I gain access to those variables from a .cs class file?
View 3 Replies
Dec 23, 2010
I have class that Inherit from UserControl Class.
public class Module : UserControl
{
// Custom Property And Method
}
How can i load a UserControl (.ascx) and convert to my Module Class?
UPDATE :
the error is : Unable to cast object of type 'ASP.UC_acsx' to type'BICT.Module'
my class is like this :
namespace BICT
{
public class Module : UserControl
{
public Module()
{
// Some Initial
}
// and some extra property exp.
public int Index{ get; set;}
}
}
is somthing wron with my code?
View 3 Replies
Mar 8, 2011
Supposing I have a user control like this <MyTag:MyWidget runat="server" /> I am wondering if I can do something like <MyTag:MyWidget runat="server" MemberHeight="400" PublicHeight="200" /> So that in MyWidget.ascx I can have <div height="<%=IsLoggedIn ? MemberHeight : PublicHeight%>"> or something like that...? Because I want the height to vary in each page that is using this widget.
View 2 Replies
Mar 23, 2010
I have a page which holds a custom webcontrol and a usercontrol. I need to reference of webcontrol in usercontrol class. So, I make the declaration of webcontrol as public in page class. But, when I do "this.Page.", I don't see the webcontrol listed in list provided by intellisense. Most probably, I am missing something.
In an asp.net page, how to get a reference of a custom webcontrol from a usercontrol?
View 3 Replies
Mar 24, 2010
I have a page which holds a custom webcontrol and a usercontrol. I need to reference of webcontrol in usercontrol class. So, I make the declaration of webcontrol as public in page class. But, when I do "this.Page.", I don't see the webcontrol listed in list provided by intellisense. Most probably, I am missing something.
In an asp.net page, how to get a reference of a custom webcontrol from a usercontrol?
View 4 Replies
Nov 26, 2010
I have created my own custom usercontrol(.ascx) consisting of labels and image etc. I need to be able to click on this control but i dont know how to add a click event to it.
Basicly i want this whole control be like a huge button which i can click on.
View 6 Replies
Feb 1, 2010
I am trying to create a more detailed item template for the standard CheckBoxList control. It exposes an ITemplate property called TemplateControl but I wasn't able to find a straightforward resource on how to actually use it. Here's the code I have so far:
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
Dim items As New List(Of ListItem)
items.Add(New ListItem() With {.Text = "A", .Value = "1"})
items.Add(New ListItem() With {.Text = "B", .Value = "2"})
items.Add(New ListItem() With {.Text = "C", .Value = "3"})
Dim lst As New CheckBoxList()
Dim tpl As ITemplate = LoadTemplate("~/CustomListItem.ascx")
Dim g As New TemplateControlWrapper()
tpl.InstantiateIn(g)
lst.TemplateControl = g
lst.DataSource = items
lst.DataBind()
Form.Controls.Add(lst)
End Sub
Class TemplateControlWrapper
Inherits UserControl
End Class
It seems to be ignoring the TemplateControl property completely.
View 2 Replies
Jan 13, 2010
I'm setting up a web application with multiple forms. Each form is defined within an asp:FormView with the DataSource set to an ObjectDataSource. Each form contains it's own set of fields and always contains one or more blocks of fields, which are the same for multiple forms.
Because this blocks are the same, I decided to define them in a custom usercontrol. The questions that came up with this:
How can I use the same datasource for the input fields in the usercontrol as in the 'higher' asp:FormView?
Is it possible to use DataBinding.Bind() for the input fields in the usercontrol, with this same datasource?
View 1 Replies
Jul 23, 2010
I have on my Page a Label control and custom UserControl. I want that, when something appears in the UserControl, it shoud change e.g the Label's Text property (as I mentioned, the Label doesn't belong to the UserControl). How to do that ?
View 4 Replies
Feb 26, 2010
I have a particular scenario and I would like to know how I can implement it in the most efficient way. I also have some queries related to this. The application is a AJAX 1.0-Enabled ASP.NET 2.0 Web application.
I have a link, which when clicked I need to show a pop-up div. The contents of the div will be displayed using a usercontrol. The usercontrol will display the contents based on a query string value.
I would like to know:
1. How can I implement this in the most effecient way. I don't want to use a separate page on which I will have the usercontrol and then display the page in the div.
2. Suppose I call a JS function ShowDiv() on the click of the link, to display the pop-up div. Say, I call the function this way ShowDiv('querystring'). Now how will I pass the value 'querystring' to my usercontrol.
View 1 Replies
Feb 16, 2010
I want to embed some image and java script file in usercontrol and extract them with code like this
[Code]....
i tried similar code that use this technique in custom controls , and it works ...
but i want use this technique in usercontrol ,
can any one put a sample source code or explain how can i use this technique in usercontrol ?
View 5 Replies
Jul 28, 2010
I have a custom control in an aspx page that has a property named Size
public int Size
{
get { return Convert.ToInt32(ViewState["CreativeSize"]); }
set { ViewState["CreativeSize"] = value; }
}
This property is set in the aspx page to a value lets say 500 during a postback called by a Button control that is in the page (not in the custom control).
I also have a button inside the custom control that raises a postback like this
protected void btnUpload_Click(object sender, EventArgs e)
{
if (fuBannerfile.HasFile)
if (fuBannerfile.FileContent.Length / 1024 > this.Size)
;//code here not important
}
When this event is called the "this.Size" property is 0. I also noticed during debugging that during Page_Load of the page, if i access the property like this:
int size = customControlId.Size;
the property is set to 500. But after that when the debugger reaches the event inside the control the property is 0.
View 1 Replies
Jun 16, 2010
I have created lots of UserControls, but never tried CustomControl.Recently i created a Photo Gallery UserControl using Listview & Visual LightBox.Now i want to publish it as CustomControl.Here is my UserControl's code :
<link rel="stylesheet" href="LightBoxGallery/css/vlightbox.css" type="text/css" />
<style type="text/css">
#vlightbox a#vlb
[code]...
View 1 Replies
Apr 13, 2010
Using the ValidationProperty I've managed to connect a RequiredFieldValidator with my custom control. When I enable client script in the validator, JavaScript errors occur.
Is there a way to tell the RequiredFieldValidator how it can validate my custom control in the client?
View 1 Replies
May 27, 2010
I created a customDropdown usercontrol with Events and It worked fine.
Now I stored the path of the ascx file in the database table and i want to Load the ascx file and handle the Events dynamically in an aspx page.
To Load the usercontrol and access the public properties and method, I need to know the object i am trying to load, right?
For Example
FeaturedDDL c = (FeaturedDDL)Page.LoadControl("~/FeaturedDDL.ascx").
But I dont want to hardcode objectType "FeaturedDDL", coz i dont have that stored in my Database field.
Since I am loading the usercontrol by getting the path and name of the usercontrol from the database table,how will I know the ObjectType at that time?
How to accomplish that and also how to handle the events for these type of situation?
View 1 Replies
Jan 25, 2011
I tried both, loading the usercontrol when needed and I also tried adding it directly into the aspx.
Nothing worked. With the second one (what's meant to be the easiest option) I tried with delegates and events (but can't access de usercontrol event from page) and tried with properties (I can access properties but they're always empty)
View 12 Replies
Jun 12, 2010
I have a user control that consistes of a dropdown menu, a label, a textbox and a button. It resides in a html table, what i would like to do is on a keypress, such as the "insert" key, i would like to add the same control again directly on the next row, I have used programs that do this, but for the life of me can't figure out how its done...
View 1 Replies
May 13, 2010
[VS 2010 RC1, .NET 4.0, VB.NET]
I'm working with a simple UserControl someone at my company created. It's basically just a DropDownList with a RequiredFieldValidator and some added properties (such as "Required", which controls the CSS styling of the DropDownList and whether the RequiredFieldValidator is Enabled or not).
Here is an example of the UserControl usage where a SqlDataSource is used to populate the ListItemCollection. I'm trying to specify an intial ListItem below (and would like the ability to add multilple ListItems if necessary) but can't seem to get this to work...
[Code]....
My code-behind looks as follows:
[Code]....
I've found several posts related to this but cannot seem to get the declarative ListItem to be added to the DropDownList.
I understand that using a WebControl is another option, but I'd like to learn how to get this method to work if possible.
View 5 Replies
Feb 21, 2011
How can I create a UserControl with a collection-type property which has a collection editor?
I've a CompositeControl with an ArrayList-type property which has CollectionEditor-type designer. You can see this property on Properties window with a "..." button which launches a collection editor. This works fine and all but I want to apply the same to a UserControl and I've couldn't manage to pull it off so far. I've done the same thing what I've done with my CompositeControl but the property either doesn't even show on Properties window of the UserControl or shows as a single value property with no "..." editor button.
This is what I've done with CompositeControl:
[Code]....
View 1 Replies
Feb 11, 2011
I have a DetailsView control bound to an ObjectDataSource within a User Control (.ascx). It appears that the DetailsView.OnDataBound event is being fired on every page load or postback.
I do not see this behavior with a similiar DetailsView directly placed on an aspx page.
View 1 Replies