Web Forms :: User Control With Declarative Paramaters?
May 19, 2010
Is there anyway to pass parameters to a custom user control using declarative paramters.E.g.
<MyUserContrl id = "" runat="">
<PARAM Title = ""/>
<PARAM SelectTable="" />
[code]...
View 6 Replies
Similar Messages:
Jan 4, 2010
How do you evalute a null sql output paramater. I've tied several ways but can find one that works. I always get an error code of Conversion from type 'DBNull' to type 'String' is not valid.
I've tried both IsDbNull and if the value = nothing - both return the same error.
Code:
If IsDBNull(e.Command.Parameters("@JobCount")) Then
Me.lblInternalJobCount.Text = 0
Else
Me.lblInternalJobCount.Text = e.Command.Parameters("@JobCount").Value
End If
'I have also tried checking for nothing and that doesn't work either
View 2 Replies
Jan 1, 2010
I have a problem with my SQL statement that only needs to show future dates in the Gridview.I use vb, vs 2005.I want a DateTime Field(TEndDate) to act as a control field in that only future dates (WHERE TEndDate >= Now.Date.Date) should be returned.It asks for my paramaterized value when I'm building the query.I'm unsure about the source I should select for the query.(The options are: None/Control/Cookie/Form/Profile/Querystring/Session)I'm losing my mind with this!Here is my code:
[Code]....
View 2 Replies
Nov 1, 2010
I need to send an array of strings to a stored procedure and then use that array of strings to create a filter of the data returned.for example I need need to send the following array to the strored procedure:
[Code]....
and use that array to run the fillowing sql command:
[Code]....
View 17 Replies
Feb 11, 2011
i want to add control 1, control 2 etc.. by default in Declarative Catalog Part
and using following code
[Code]....
but it only displays last item in it
any one guide me what mistake am i doing or what is the solution to my problem?
actually i want to give default 4-5 webparts options so that user could add it to page
View 1 Replies
Jan 17, 2011
I'm using Visual Web Developer 2010 Express with C# 2008 and .NET v4.0 to create a website which will have a database application. The database is SQL Server 2008.
I would have searched this forum for similar questions but I can't find a 'Search this forum' option! So I apologise if someone has already answered this.
I've successfully displayed rows from my database by dragging and dropping a GridView and an SQLDataSource control onto my page, and by using the Connection Wizard to set them up. But when I go live with my new pages, I will have to put my database in a different folder, and until I edit the web.config connection string to point at it I expect to get an exception.
I understand that when you try and open a database connection, this is the perfect place to use try...catch exception handling. But all the examples I can find put the try-catch code on the Button_Click event! Where should I put it? I can' t find anywhere where my controls actually attempt to open the database!
I know I could rip out what I've done and write all the code to connect to the database myself, but as I've finally got everything to work I would prefer to make the change as small as possible. So, what is the minimum change I have to make to add exception handling to my datasource/ gridview?
View 6 Replies
Jun 4, 2010
I don't think I understand fully how ASP.NET does inheritance of controls.I have a user control, ucBase, which has an asp.net label in the ascx file. Code behind references the label and it works fine during run time if the control is not a parent for another user parent.
If I have another user control, ucChild, inheriting from ucBase, the label in ucBase's code is always null. ucChild has no controls in its ascx fileThe server controls (like the label) needs to be declared in the ascx file and not created programmatically.What needs to be done for ucBase to see its own controls when it's a parent user control?
View 1 Replies
Apr 19, 2010
is it possible to declarative pass properties (in my case property of DataContext type) to User Control without DataBinding.
Now code looks like this:
[code].....
View 4 Replies
Sep 10, 2010
I've got a web site that has a master page and that master page (mpMaster that has a user control ucControl1) which has a sub user control (ucControl2), this user control has a property which accepts a value. Now, I have a page that uses the master page
and on this page I have another user control (ucPageControl), I need to find a way of setting the value in ucControl2 from ucPageControl. Is this possible at all?
View 5 Replies
Feb 17, 2011
I am trying to assign user control from another user control ..first time its binding control successfully but when we refresh the data its giving error
saying "Object reference is not set an instance".
how to refresh data from another user control ...
My senerio below :
1 Aspx page
2. User control
calling usercontrol databinding method from aspx page but once it get refreshed ,not allowed to bind it again..
View 2 Replies
Mar 9, 2010
What is the format for databinding to a complex "object"? I have a linq to sql class that has containment, i.e object.containedobject.I want to reference the sub objects fields declarative.So I've tried my MySubField.MyBasicProperty and that did not work, as well as, MySubField_MyBasicProperty.
View 2 Replies
Jul 16, 2010
I know that in ASP.NET (talking about 2.0 here primarily) one can set a property on an object that takes a collection of things (an enumerable type I'm guessing is the trigger) and then reference it declaritivly. For example:
<ObjectDataSource properties="blahblahblah">
<SelectParameters>
<asp:Parameter />
</SelectParameters>
</ObjectDataSource>
It is the <asp:Parameter /> part which is the root of my question. Say I wanted a simpler collection on a type. Say a List<String> or if generics are out, an IntegerCollection or StringCollection. How would I use that declaratively? Is <string value=''> allowed, or can I put raw values into it like <StringCollection>string, string, string</StringCollection> or what?
EDIT:
I feel like I was not clear enough in my question. I understand that ObjectDataSource implements its SelectParameters property as a ParametersCollection, and that one can use that property declaratively (in an ASPX page) to set up Parameter types within that collection. What I'm wondering is if I made something like StringCollection as a property on another control, is there a syntax (in ASPX) for adding strings to that collection? Or would I have to define a wrapping class like how DropDownList takes ListItems to fill its collection?
View 2 Replies
Feb 14, 2010
I have a binded dropdown control in the gridview under edittemplate. Now i wanted to populate the second dropdown in the same gridview based on the first selection. I dont have options but use the gridview & declarative coding.
Also i am using the objectdatasource here.
View 1 Replies
Dec 15, 2010
I'm trying to write a simple declarative html helper: [Code]....
The helper works fine if I embed it into the page I want to use it on. But if I move it to a separate .cshtml file and place that file in the ~/Views/Helpers directory, my view can't be compiled anymore because the helper is not found.According to Scott Gu's blog article on Razor it should work.
The only workaround I have found so far is placing the Html helper in App_Code and Referencing it as @[MYHTMLHELPERFILENAME].Echo(...) . This works but is a bit messy since I don't want to repeat the name of my extension method (Echo.Echo("inputstring"), nor do I want to put all of my html helpers into one single file (something like MyHtmlHelpers.cshtml).It certainly isn't what Scott announced either, so I guess I must be doing something wrong.
View 4 Replies
Apr 5, 2010
I use declarative roles in my MVC.NET controllers and I have a custom membership & roles provider.This works fine:
[Authorize(Roles = "ADMIN")]
Also, I have a base MVC.NET CustomController class that all controllers derive from, and it has a "currentUser" property that is auto-fetched from the session on demand, so all controller code just refers to "currentUser" and doesn't worry about sessions, httpcontext, etc. I've implemented the membership provider properly, as it works with other parts of the framework that just deals with providers, but until now I had not tried to access the "User" principal from a view.What is the simplest syntax for check roles in a view page? I know I can use a helper to generate a partial view but I don't want that here, I want to explicitly wrap some sections of a page in some role checks.Something like this:
<% if(currentUser.IsInRole("ADMIN") { %>
...
<% } %>
View 1 Replies
Apr 16, 2010
All I would like to be able to do is include one user control within another! Is this possible? I have spent the last hour searching the internet and it seems that I can't find a single thing.
In classic ASP it would be something like:
<!--#include file="EditProject.ascx"-->
I tried this but no luck!
Parser Error Message:
There can be only one 'control' directive.
Source Error:
[Code]....
Line 1: <%@ Control Language="VB" AutoEventWireup="false" CodeFile="EditProject.ascx.vb"Line 2: Inherits="Controls_WebUserControl" %>Line 3: <form runat="server">
View 3 Replies
Sep 6, 2010
I have a bunch of controls like the following in the EditItemTemplate of a ListView, with LINQDataSource:
[Code]....
I'm curious to know why the database won't update on the click of the Update button:
[Code]....
According to all I've read, the above code should be sufficient. Since CommandName is set to Update, it would seem that no code-behind is necessary.
View 20 Replies
Mar 22, 2011
i have 2 user control : uc1 and uc2. and i have button in uc2 i call button1, i want to set commandArgument of button1 from uc1, how can i do this?
View 5 Replies
Nov 9, 2010
I want to use a couple of instances of the same control on a page. The user control is intended to display a list of records in a repeater. The aim is that the second control will show a list excluding the IDs in the first control The control has a number of public properties, including IDsInThisList, and IDstoExclude. The query will exclude the IDs in the second property.
What I would like to do is get the record IDs from the first instance of the control (IDsInThisList), and pass them to the second contro as the IDsToExclude.
I have a test page where I am setting the properties of the controls in code. As you might guess, it's not working! The first control displays the top 3 items, as desired, but the second display the records 1-7, rather than records 4-10 because it is not receiving the IDstoExclude from the first control When I response write the IDstoExclude from the first control in my testpage, the string is empty. (if I do it from within the control, it shows the IDs)
How can I get the controls to fire in order and pass values to each other?
Screen grab of test page + uc and test page code attached
[Code]....
View 5 Replies
Jan 11, 2010
i have:
- Default.aspx;
- user1.ascx: 1st user control containing repeater;
- user2.ascx: 2nd user control containing a detail view of row.
In page.aspx i dinamically load the repeater inside a user1.ascx.
after i want to dinamically load the 2nd user control also in default.aspx by a button inside a user1.ascx.
How i can do this? I can't load user2.ascx inside user1.ascx but only in aspx page.
View 2 Replies
Jul 28, 2010
I have a requirement where i need to access the methods of one user control in another user control.
View 8 Replies
Mar 22, 2011
i would like to ask about how can i open user control page when i click a button on parent page, also, can i call parent's method from user control page and then refresh parent page?
View 8 Replies
Feb 18, 2011
I'm attempting to create a simple menu user control just as outlined here.
The attached code results in an "Object reference not set to an instance of an object" error, but I can't figure out why.
<%@ Master Language="VB" CodeFile="MySite.master.vb" Inherits="MySite" %>
<%@ Register src="Controls/Menu.ascx" tagname="Menu" tagprefix="my" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">......
View 1 Replies
Jun 11, 2010
I have to access the parent form's controls inside an event handler method on my user control's code behind.
View 4 Replies
Jul 4, 2010
i have a web page and inside the page has a placeholder that contains 2 user controls and both visible set to false.
When i click on button1 on the page, it will set the visible of usercontrol1 to true. May i know how do i do it so that when i click on button2 that IS INSIDE usercontrol1, it will hide usercontrol1 from placeholder and set usercontrol2 visible =true?
View 2 Replies