Linking A CSS Stylesheet With A Custom Control?
Jun 4, 2010
I'm developing a custom control which is a composition of tables and buttons. I also have an external CSS stylesheet that defines the styles for these elements.
The Control's type is CompositeControl, under namespace MyControls and the definition of the class is in a class file CompositeControl.cs and the dll file generated is named MyControls.dll
The stylesheet is called styles.css and is in the same folder as CompositeControl.cs
For each control (Button, TableCell, etc.), I have specified the CssClass property.
When I add this control to my ASP.NET webpage and check the HTML source when run at localhost, I see all the control tags have the class attribute correctly set, but the source doesn't include the <link> tag which is necessary for including an external stylesheet.
View 1 Replies
Similar Messages:
Jan 8, 2010
How can i use the User Interface of the Visual Web Developer to link my own custom html form code in my asp.net page into sql database?What are the steps?
View 3 Replies
Jul 27, 2010
What is the best method to register a stylesheet once on a page from a customer web control? the page uses an UpdatePanel for async calls. I tried just putting the <link> tag in ScriptManager.RegisterClientScriptBlock(), but I get this error:
The script tag registered for type 'MyControl' and key 'MyKey' has invalid characters outside of the script tags: . Only properly formatted script tags can be registered.
If I try to add it to the page by adding it to the control hierarchy, it shows up once for each instance of my control on the page.
View 1 Replies
Jan 13, 2010
I got this question which I trying out for month and I still can't figure out.This is the scenario (Sorry for the poor English)There is a database that have information such as the employee particulars (Name, Mobile, address etc)How do I link the user to the database as such,When the user (John) login to the website, the database will display
(john) particulars only and not the other user's particular?
View 3 Replies
Jan 5, 2010
I'm trying to solve an issue in an elegant way. The problem at hand is I have 2 aspx pages (I'll call then Page1.aspx and Page2.aspx).
Page1.aspx contains an AJAX tab control with 3 tabs (I'll call the control Tab1). Page2.aspx also contains an AJAX control with 3 tabs (I'll call the control Tab2).
My question is, is there an elegant way to have a hyperlink on the second tab of the Tab1 control that links to the thrid tab on the Tab2 control? And, is there a way this linkage can be represented as a web address (example : http:\someserversomeappsomepage.aspx???TabControlIdentifier,???TabNumber.
The current methodology we are implementing is to pass the TabControlID and Tab number as querystring values and the set the focus in the codebehind of the page. But the only way I can think of to implement this across multiple pages is to have all the receiving pages implement the same overriding class that handles the focus issue.
View 1 Replies
May 2, 2010
I am using c# with asp.net and SQL Server 2005 as backend. I want to use dropdown list control in a form to populate a textbox. The dropdown control is linked to a column in the database. How can I code this in c#?
View 1 Replies
Feb 3, 2010
I have a custom control that is based off the gridview control located at: here The control is basically a gridview that automatically creates a column of checkboxes that can be used to "check" individual rows in the gridview. During the gridview's "CreateColumns" event, the "checkboxcolumn" is created dynamically. The checkboxcolumn also contains another checkbox in the header that is used to "select/deselect all" checkboxes in the column. Since the gridview does not automatically remember the state of the checkboxes in the checkboxcolumn on postback, I added a method to the control called "SaveCheckBoxState" which stores the indexes of the checked rows in Viewstate, and then I modified the "OnRowDataBound" event to check the Viewstate and reset the checkboxes based on the Viewstate.
I then added a call to "SaveCheckBoxState" in the gridview's OnSorting and OnPageIndexChanging events. This works great so long as I'm sorting or changing pages. However, I need it to update the viewstate everytime someone clicks or unclicks one of the checkboxes. At this time, the checkboxes are rendered with an onclick event that calls some javascript to highlight the row, or in the case of the checkbox in the header, to select/deselect all checkboxes. I need to call the "SaveCheckBoxState" method from the javascript used by the customcontrol, or I need to find a way to modify viewstate from javascript and perform the same action as "SaveCheckBoxState".
I've tried adding the "SaveCheckBoxState" to the onclick event declaration in the checkboxes, but when run, it simply tells me that the method is undefined. It doesn't exist in the parent page, and I don't think I should have to make an event for the parent page to pass the click to. It seems to me this should be all self contained within the custom control. Does anyone know how I can acheive this? Here is the code for the gridview OnPreRender event where the onclick event of the checkbox is set:
protected override void OnPreRender(EventArgs e)
{
// Do as usual
base.OnPreRender(e);
// Adjust each data row
foreach (GridViewRow r in Rows)
{
// Get the appropriate style object for the row
TableItemStyle style = GetRowStyleFromState(r.RowState);
// Retrieve the reference to the checkbox
CheckBox cb = (CheckBox)r.FindControl(InputCheckBoxField.CheckBoxID);
// Build the ID of the checkbox in the header
string headerCheckBoxID = String.Format(CheckBoxColumHeaderID, ClientID);
// Add script code to enable selection
cb.Attributes["onclick"] = String.Format("ApplyStyle(this, '{0}', '{1}', '{2}')",
SelectedRowStyle.CssClass,
style.CssClass,
headerCheckBoxID);
// Update the style of the checkbox if checked
if (cb.Checked)
{
r.BackColor = SelectedRowStyle.BackColor;
r.ForeColor = SelectedRowStyle.ForeColor;
r.Font.Bold = SelectedRowStyle.Font.Bold;
}
else
{
r.BackColor = style.BackColor;
r.ForeColor = style.ForeColor;
r.Font.Bold = style.Font.Bold;
}
}
}
View 1 Replies
Mar 4, 2010
I have a custom control which inherit from the Table class and in the constructor, it takes a an integer as an argument. There is no empty constructor.
Is there a way for the user to set that variable in the properties window after they drag the control onto a form.
I know some .NET controls, you can set the source for the parameter to different things like another control's property, QueryString using just the properties window.
Right now, I have to create the control dynamically. I read the query string and then created the object.
View 1 Replies
Dec 24, 2010
here's a situation and I would appreciate your response.
I have programmatically created the Wizard control:
Page_Load(obj s, evargs e)
{
Wizard ClaimDetailWizard = new Wizard();
foreach(int item in selectedItems)
{
//create new step
//added custom control to new step
//add step to wizard
}
//added wizard to a placeholder on a page
}
Based on List I get from Session i added new steps to my wizard To each step I had added a custom control
Each custom control in tern contains another custom Gridview Control in it.
So here's the problem when the page loads for example for two steps. All is good Wizard does what it's supposed to do.
But when I try to use sorting or paging in that custom Gridview. Somehow it displays the gridview I should see in the next step of the wizard.
Also what I'm noticing through debugging. Is that when I press next in the wizard I go back to the original page where I do all of the code specified above, and it recreates the wizzard. But it goes to the next step. Is this the way wizard supposed to work? Just doesn't seem very efficient.
View 1 Replies
Dec 20, 2010
created a Custom Textbox Control that is intended to be a "masked date" textbox, so that I can handle different ways a user might enter in a date and make it work no matter what.I did this by creating a custom control with 3 separate Textboxes one for month,one for day one for year,then do some handling for different things that could be entered and it would all work.
The problem I am having is,when I add this control to the page,if I do an alert to check the Text value of the custom control it just gives me "[ServerControl1]" even if I enter in a date.
I tried doing an AutoPostback after entering so that it would refesh the Viewstate to have the values of the textboxes but the control doesnt seem to actually postback, even though I have it enabled.accessing the Textbox value after someoen
has entered a date?first custom control I have created and have been using google.
My Server Control Code is as follows:
[Code]...
View 1 Replies
Jan 31, 2011
I have created one user control for changing the theme of the page where i have several buttons and on click of each button i am applying the theme of clicked buttons color and for that i have created several css files like red.css, blue.css , green.css etc.
now i want to apply this theme to the page but i am not able to do that from the user control as because i am not getting the stylesheet property in the page and thus i am not able to work further.
can anyone tell me how can i apply the theming from user control to the page its being called.?
View 2 Replies
Oct 27, 2010
I have created a user control and am ready to convert it into a custom control. I am trying to follow:
[URL] the steps mentioned in the link.
I am not seeing Build / Publish Web Site option.
I am using VS 2008. I only see Publish User Control but it doesn't give all the settings mentioned below. When I do publish user control, it just copies the ascx file to the desired location. how can I convert the user control to custom control.
View 2 Replies
Oct 18, 2010
I created an Extender which has a custom property that drills down a list XML elements from an xml file, where users can select xml elements during design-time. This works perfectly fine. However, my code only has a hardcoded xml filename (source of the xml elements list) and I need to change this by maxing the xml file user-specified.
What I did is that I created another control (panel) which has a custom property that when clicked (through the ellipsis), it will allow a developer to select the xml file which is supposed to be the source xml file that the Extenders shall use. The filedialog from custom panel's property works perfectly fine.
However, my problem now is that when I drag-drop my Extender, I cannot find a way to get the property value of the custom Panel Control which contains the xml filename. I tried creating a static variable which I thought the custom controls can share but VS2010 is breaking.
View 4 Replies
Oct 12, 2010
I have 3 pages in each page there is a portion of page where it is common in all these three pages.Thought of making the common stuff as a separate control either User control/Custom control.Any suggestions on which one should i use custom/user control
View 2 Replies
Jan 3, 2011
Hope this is the correct forum for this question. I am using VWD 2010 an have a web project and get the following error upon execution:
Parser Error Message: Unknown server tag 'custom:AjaxValidator'.
My code is as follows in the .cs file:
[Code]....
[Code]....
View 1 Replies
Mar 22, 2011
I am trying to build a custom composite control, which allows me to add custom content to each child control. It's a similar concept to what you have with a GridView and TemplateColumn. The markup used to place the control on the page would end up being something like this:
[Code]....
I have the code below, which allows me to put that markup on the page without throwing any errors, and it renders all the correct HTML, except it doesn't render the contents of the ColumnTemplate. I have replaced the Render() code with a comment because it's quite long winded and doesn't add anything important here:
[Code]....
I have tried to follow examples on MSDN and other forums but I can't make this work. I think I'm missing the code to render the contents of the template, but I don't know how to hook that up.
View 1 Replies
Oct 22, 2010
I want to create a custom control where I define several specifically named DIV sections. The code-behind logic of the custom control will perform operations on these named DIV sections. The page where the custom control is hosted needs to be able to add named controls to the DIV sections and perform operations on these named controls added to the DIV sections.
Let me explain a little further. In the custom control, I want to have code behind logic that fires the following Page Event and uses a condition to make one or another specifically named DIV section visible or not:
< _
ToolboxData("<{0}:BaseDetails runat=""server""></{0}:BaseDetails>") _
> _
Public Class BaseDetails
[code]...
how can I create a custom control which is able to generate the named DIV sections "DetailsNameDiv1" and "DetailsNameDiv2" where my custom control can check a condition and make one or the other visible. Also, I need to be able to add controls to these named DIV sections when I host the custom control and the control that I add to the named DIV section needs to let me set values of these controls from the code behind logic of the page (or usercontrol) where the custom control is being hosted (in my example, I am adding TextBox controls that I want to set the Text property from a SQL Data Reader).
View 3 Replies
Feb 25, 2011
I have created a really simple custom control to render panels into a page. The code is below. When I use my control and add any webcontrol to it, after each page postback the contents of these child controls vanishes.
I must have missed something really simple but run the example to reproduce this. Can anyone please enlighten me as to why the controls are being 'emptied' of their contents, and how I stop this occuring?
Here is the code for the control
[Code]....
And here's how I am using it in a sample page:
[Code]....
[Code]....
View 16 Replies
Jul 8, 2010
I'm building an n-tier application, with the web client and the class library separate. I'm also using the factory pattern of development, using interfaces to act as containers for different objects they are associated with. The problem I'm expreriencing is that I declared a public interface class in the class library and I can create an instance of it in in my aspx pages but whenever I declare it in my custom control code-side, i get an error, like so:
Error 20 The type or namespace name 'IContentMaker' could not be found (are you missing a using directive or an assembly reference?)
notge that I have inherited the class library namespace using the 'using' keyword just in case you are wondering. My code is like so:
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using TQO_Classes ; //importing the class library project
public partial class PageContentMgr : System.Web.UI.UserControl
{
private IContentMaker _data; //this line throws the error, it works fine on aspx pages
View 1 Replies
Jun 15, 2010
I have an ASP.net web application project written in VB. Am trying to test a cobbed-together "MyTreeview" control put together from C# code that's been converted.
I think this will come "close" to what I'm trying to do - just get a treenode to have a CSS tag and render properly.
I have an App_LocalResources directory and a file called CustomTreeNode.vb. Inside that file is the following code:
[Code]....
[Code]....
[Code]....
View 1 Replies
Dec 31, 2010
I have a Custom Server Control with a Collapsible Panel Extender. I want to be able to keep the Collapsable state (open or closed) when doing a Post Back.
Here is my Custom Control's ASP code:
[Code]....
View 1 Replies
Sep 3, 2010
Iam developing a custom checkbox control deriving from the 'compositecontrol' which i need to use it for a composite control purpose.
public
class
TngCheckBox :
CompositeControl
{
i have written the required properties which are working fine except the "checked" property. here is my code for 'checked' property. i tried both the below ways (commented one and not commneted) . the problem is the 'checked' value is not setting the value at the get set part of the property.its assigning the value at the design time , but when i check and uncheck its not updating the property value.which is resulting me wrong .
[Code]....
View 2 Replies
Oct 15, 2010
Iam developing a custom checkbox control deriving from the 'compositecontrol' which i need to use it for a composite control purpose.
public
class
TngCheckBox :
CompositeControl
{
i have written the required properties which are working fine except the "checked" property. here is my code for 'checked' property. i tried both the below ways (commented one and not commneted) . the problem is the 'checked' value is not setting the value at the get set part of the property.its assigning the value at the design time , but when i check and uncheck its not updating the property value.which is resulting me wrong .
[Code]....
View 4 Replies
Dec 26, 2010
I have built a custom control. when i add this custom control in my page twice or more then the it write only one time of its render contest data.
View 4 Replies
Jul 6, 2010
I try to mak a custom textbox. Something pretty easy to do but I can't figure out one thing. When I write my textbox in designmode I have this <custom:Textbox runat="server" ID="Textbox1">Test</custom:Textbox> The problem is The textbox is a webcontrol I added to my class [Parsechildren(false)] like this [Parsechildren(false)]
public class Textbox : WebControl
{
}
now the problem is I want to able to write the Text from the textbox between the beginningtag and andingtag but I want to disable every other control in designmode. When I add < between the tags then you can see you can write all tags between it. disable all controls except literal between the tage in designmode?
View 4 Replies