How To Use Higher Level Datasource In Custom Usercontrol

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


Similar Messages:

Web Forms :: Menu With Custom Second Level Items?

May 28, 2010

my menu control is bound to a sitemap. I would like to be able to customize the second level of the menu (the dynamic level), so that I can insert an item image, link and text. An example is the top menu in [URL]

Is it possible to achieve using asp.net menu and sitemap ? maybe using the dynamic item template of the menu ?

Here's my code so far:

[Code]....

my site map:

[Code]....

code that binds to site map:

[Code]....

View 3 Replies

DataSource Controls :: Error Handling At Datasource Level

Jun 19, 2010

I have a website which displays news information. It displays the titles at the default (home) page and when click it shows the full story.

I use object datasource to load the news titles.

Now, sometimes the database server lose its connection or changes to the database and it affects the whole website because error is reported at the Application level. I would like the Home page to still show but the section where the news titles usually appears will now show an error message that the database is down (Refer below my part of my code).

How can I achieve that?? I tried to do that at the page_error level but it displays nothing. I don't want to pass the error to application level, I want to handle at datasource load/binding level so that it display this error message at the news section and other home website information can still be shown.

[Code]....

View 1 Replies

MVC Class Level Custom Data-annotation And ModelState Keys?

Apr 10, 2010

I have custom class level validation attribute, inheriting from ValidationAttribute, on my model.

How come it doesn't register a key in the ModelState when its IsValid is false? I can see the the error message in the ModelState.Values collection, but the ModelState.Keys collection only shows an empty string "". Can I provide a key for it - presumably this is because its not assigned to a property?

I wanna be able to use ModelState.Remove in my controller to remove this error upon a certain condition, but I have no Key!

View 1 Replies

Raising Custom Event - Cannot Access WebErrorEvent Due Its Protection Level

Apr 29, 2010

I use SqlWebEventProvider to log the exceptions to sql server, and it works fine.

I also want to log custom exceptions to aspnet_WebEvent_Events table programmatically. Similar to - [URL]

WebBaseEvent.Raise(new WebErrorEvent("My Error message", null, 5000, e)); I get an error saying "Cannot access constructor 'WebErrorEvent' here due its protection level.

View 2 Replies

MVC :: How To Display Model Level Custom Data Annotation Validation Error

Nov 30, 2010

I am a MVC newbie & am lost in various ways validation can be implemented in my application.

I created a custom model-level data annotation validator attribute, but am unable to display its error message in the view. Basically, I have let's say 5 properties in the Entity class Job (model-level custom attribute called UniqueKeywords defined on it):

1) LoginID: value comes in the URL

2) Title: Required property level attribute defined on it

3) CatID1, CatID2, CatID3 - 3 categoryIDs - these are dropdowns in the view with same list of keywords in all 3.

I want to mandate that the values picked by the user in all 3 category dropdowns should be different.

With reference to the code pasted below, here is the explanation of what happens:

When I submit the form without specifying a title or picking anything from any of the 3 category dropdowns, the validation occurs for the property level Required attribute as well as model level uniquekeywords attribute, but the error is displayed only next to the required field "Title". I can confirm that the custom validation also works by filling in some text in the Title field & then re-posting the form...this re-displays the view, but the error message "Category cannot be duplicated" is not displayed.

Only relevant code sections are pasted below:

My Entity class code:

[Code]....

View 10 Replies

AJAX :: Rating Control Can't Have Currentrating Higher Than 5?

Jan 21, 2010

I have this:

[Code]....

This code throws an error:CurrentRating must be greater than MaxRatingParameter name: CurrentRatingWhen I change the code to this, it DOES work:

[Code]....

View 2 Replies

C# - Convert UserControl To Custom Control?

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

C# - Custom Attribute In A UserControl (ascx)?

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

How To Get A Reference Of A Custom Webcontrol From A Usercontrol

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

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

DataSource Controls :: Nhibernate Second Level Cache?

Apr 17, 2010

i am trying to use nhibernate second level cache, i have configured my cfg as

<property
name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider,NHibernate.Caches.SysCache</property>
<property
name="cache.use_query_cache">true</property>
<property
name="cache.use_second_level_cache">true</property>
<property
name="cache.default_expiration">120</property>

and also enable cache in presistent class as <cache
usage="read-write"/>

now what steps i have to take to check whether the cahce is working or not, do i have to write some C# code for cache?

View 2 Replies

C# - Create Better Quality Higher Resolution Thumbnail Image

Sep 28, 2010

I am looking c# code which creates better quality higher resolution thumbnail image. i am having an image of dimension(600 * 900) and i need to create thumbnail of dimension (100 * 100) with high quality.

View 3 Replies

Web Forms :: Handle Error On Page Level Or Application Level?

Jan 31, 2011

I have to handle error related to web application. I am not sure how its works. I am thinking that I will add an error page (error.aspx) and in global.asax ,application_onError, I will redirecting the user to error page and that should be enough ! i mean it will handle error automatically.

View 4 Replies

Iis7 - Configuration Granularity Between Machine - Level And Site - Level?

Apr 29, 2010

I want to be able specify to do the following: Specify configuration settings such as appSettings and connectionStrings for multiple web apps in IIS7 No editing Machine.config or the machine-level web.config Web apps are distinct web sites in IIS (not subfolder apps) Is this possible without just duplicating the configs for each app?

View 1 Replies

Web Forms :: How To Get A Reference Of A Custom Webcontrol From A Usercontrol

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

Web Forms :: How To Add Click Event On Own Custom Usercontrol

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

Replace CheckBoxList TemplateControl With Custom UserControl?

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

How To Change Page Controls Via Custom UserControl

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

Custom Server Controls :: Passing Querystring To A Usercontrol?

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

Custom Server Controls :: Embedding Resource In UserControl

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

Property From A Custom UserControl That Is Saved In Viewstate Loses Its Value?

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

Custom Server Controls :: UserControl With ListView To CustomControl?

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

Forms Data Controls :: Gridview Styling - Compare The Value And Bold The Higher Value

Jun 25, 2010

I have a gridview control having the following columns.

ContestantID
Public Votes
Judges Votes
Public Percentage
Total
Schedular ID
Formula
4
200
1
51.282
330
2
130
3
190
2
48.718
450
2
260
2
1
??
25
1
1
??
1
3
??
75
3
1
??

On the basis of SchedularID i want to compare the value in column total and make the one with higher value as bold. But the problem is i am calculate the Total column at run time inside Row databound even. So any solutions?

[Code]....

View 6 Replies

Displaying Images On The Gallery, Each Thumbnail Show The Higher Version Of The Image?

Mar 10, 2011

I have to create a webpage that shows gallery of images in a folder. The folder contains different images and also versions of them (like a basic image of xxx1_v1 and then a modification of it as xxx1_v2 and so on...Also, there are xxx2, xxx3 ....). While displaying these images on the gallery, each thumbnail should show the higher version of the image. For example, if there are xxx1_v1, xxx1_v2 then xxx1_v2 must be on the gallery page. Further, when we click on the higher/later version of an image, it must be redirected to another page which shows the other versions of that image. Should i use AJAX / Jquery .

View 3 Replies







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