.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Single web control that behaves both as button and Image button control

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net

Hi Everyone,

I am planning to create/use a webcontrol , the behaviour of this control should be in such a way that , it should act as a button or Image button based on the client using that control. I mean if the client wants to use that control as ImageButton it should expose him properties of Imagebutton control like (Image Src, image align etc..), if he wants to use that control as Button it should expose him only button properties and it should not expose any Imagebutton related properties. is it possible to implement such control? i guess i can try generics, but really i am not sure whether i can use generics to solve this problem. or there any other alternatives other than Generics..?

Thank you,


View Complete Post

More Related Resource Links

Composite Control, File Uploader with 3 image buttons one image button fires but the other two don'


Hi, I've been trying to develop my own custom controls to save me having to write all the bumf of code. I've successfully done all the easy ones but am stuck on this one. I have a file uploader that has a submit image button a view uploaded file button and delete uploaded file button. The control works and will successfully upload the file. however the view button and delete button do not.

here's the code...

[DefaultProperty("Text"), ToolboxData("<{0}:AdminFileUpload runat=\"server\"> </{0}:AdminFileUpload>")]
    public class AdminFileUpload : CompositeControl, INamingContainer
        protected Label lbl;
        protected FileUpload fu;
        protected ImageButton upload; 
        protected ImageButton downloadCurrent;
        protected ImageButton deleteButton;

        [Bindable(true), Category("Miscellaneous"), DefaultValue(""), Localizable(true)]
        public string LabelText
            get { EnsureChildControls(); return lbl.Text; }
            set { EnsureChildControls(); lbl.Text = value; }

        [Bindable(true), Category("Miscellaneous"), DefaultValue(""), Localizable(true)]
        public string FileName
                string s = (string)Vi

How can i use the image in the asp button control


Example i am having a asp button which is used to save the data in the database using the event btnApply_Click.



<asp:Button ID="btnApply" runat="server" Text="Apply"

Web Q&A: Detecting Security Settings, Printing from the WebBrowser Control, Hiding the Print Button,


how to set multiple button in single image


Hi friends,

I need to make multiple button in a single image in asp.net.

and need coding also for vb.net.

thanx in advance

Control this objectdatasource programatically from the code behind based on different button clicks

I have a page where you can search and display other data, very simple layout. 1 Gridview and 1 objectdatasource. But i have 4 possible buttons that can populate the gridview.. i would like to control my objectdatasource from the code behind based on the button you click. here is what i have right now.. but if possible, can this source not be hardcoded like this and only built in the code behind? <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="SelectDVRInfo" TypeName="DataAccessCode"> <SelectParameters> <asp:ControlParameter ControlID="ddlDVR" Name="dvrInfo" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:ObjectDataSource> I found this site with a solution to this persons issue, but i cant seem to get mine working this way. http://stackoverflow.com/questions/2404264/overwriting-controlparameters-of-datasources-in-code-behind I have  this as the code behind right now when you press the button.. what other parameter settings am i missing and is this the right order to populate them for the source to acknowledge my values?   ObjectDataSource1.SelectMethod = "SelectDVRInfo"; ObjectDataSource1.SelectParameters["MyParameter"]

Does the ReportViewer control print button work inside of a modal MSIE window?

I am getting the following two error messages when using the new ReportViewer v10 control after pressing the toolbar print button. I am only seeing this error inside of a modal popup window in MSIE. The print button in a normal popup window doesn't have this error. An error occurred trying to get the current window Error: Could not complete the operation due to error 8007f305. If anyone knows of a quick fix, please let me know. Thank you. VS2010, MSIE 8, SQL Server 2008.

How to conditionally Enable/Disable Button control using JavaScript ?

hi all... i have a Button control & a TextBox control on my web page. The Button control is initially Disabled. I want that while typing into TextBox, when the length of the contents of TextBox reaches to 12 (i.e. when i type 12th character), the Button Control should be Enabled & if the length again comes down to less than 12, the Button control should again be Disabled... How can i do this using JavaScript...?? Does anyone know how to do this...?? Please help. It's urgent... Thanx in advance to all posts !

I need to be able to disable a button inside a repeater control when an item in the data is <1

For example, I have an inventory table. If any one of the items is less then one, I need to disable the button. <asp:Repeater id="repeater1" <ItemTemplate> <asp:Button id=btnSize /> </ItemTemplate> </asp:Repeater>  

Handling Ctrl + Shift + Click on Button control

Hi All, I have to Button control in my Windows form. I have to handle 2 types of click events on this button. 1. Ctrl + Shift + Click //Allow the user to do some special task. 2. Click //Allow the user to perform normal task only. How could I handle Ctrl + Shift + Click ? Please help me out.

find the label control of gridview in save button event in C#

hi, every one..i want save the gridview in buttonsave event..here i wrote the code like thisfor (int i=0;i<gridview1.row.count;i++){label lbl=(label)gridview1.rows[i].findcontrol("lbl");Textbox txtname=(Textbox)gridview1.rows[i].findcontrol("txtname");}here i got the textbox value but am not getting label value how to get that label value..thanks in advance

FontSize does not get altered when set in a control template for a button.

Hi,  I am new to WPF.  I wanted to customize the look and feel of a button , so defined this custom style/control template :        <Style x:Key="TaskbarButton" TargetType="{x:Type Button}">         <Setter Property="OverridesDefaultStyle" Value="True"/>         <Setter Property="SnapsToDevicePixels" Value="true"/>         <Setter Property="HorizontalContentAlignment" Value="Center"/>         <Setter Property="VerticalContentAlignment" Value="Center"/>         <!--<Setter Property="Width" Value="105"/>         <Setter Property="Height" Value="35"/>-->         <Setter Property="Width" Value="118"/>         <Setter Property="Height" Value="40"/>         <Setter Property="FontFamily" Value="Tahoma"/>         <Setter Property="FontSize" Value="13"/>         <Setter Property="FontWei

Multiple instance of User Control on Page - Button Click Event

Hi, I have this Web User Control, with 3 controls:<asp:TextBox ID="txtSearch" runat="server" /> <asp:RequiredFieldValidator ID="rfvSearch" runat="server" ControlToValidate="txtSearch" Display="None" /> <asp:Button ID="btnSearch" runat="server" onclick="btnSearch_Click" /> In code behind: protected override void Render(HtmlTextWriter writer) { rfvSearch.ValidationGroup = this.ID + "_validation"; txtSearch.ValidationGroup = this.ID + "_validation"; btnSearch.ValidationGroup = this.ID + "_validation"; base.Render(writer); } protected void btnSearch_Click(object sender, EventArgs e) { Response.Redirect("ResultadoSearch.aspx?argumento=" + txtSearch.Text); } When I try to add two UserControl and I Click in btnSearch of second UserControl, txtSearch.txt returns value of first User control.How I can get the value of second txtSearch?

dynamically created button control click event not firing first time?

HI im creating a button control in page int and im assing a click event for the button control. here the click event is not firing for the first time.can anyone help me with this? here is my code. Button btn = new Button(); btn.ID = "btn"; btn.Click += new EventHandler(btn_Click); Panel1.Controls.Add(btn); Panel1.Controls.Add(new LiteralControl(""));

How to pass parameters via a button control

Hi all, I would like to pass a number of parameters via a button, (it must be a button) but I don't know how to do this, could someone please help. I've be grateful for any suggestions    

how to animate the toogle button of a expander control ?




i would like to know, how can i implement a "smooth expand/collapse" animation for a header icon (tooglebutton) of a expander control ?

may be like the icon of the AccordionItem.Header of a Accordion control.


thanks for any help



Gridview Link Button control click event


Respected Reader,

I have  Web page that uses LinkButton control inside Template Fields of Gridview.

I am trying to work on LinkButton Click event and trying to preserve the Value of LinkButton that user click, and based on that value, i want to refresh tha page data.

I used CommandName and CommandArgument property of Linkbutton, but i can use that property only in GridView_RowCommand method by checking e.CommandName expression. But the problem with that Gridview_RowCommand event fire after all other page_load activity. So the value never used in the page_load event to refresh the data in all other control.

I also tried to use OnClick Method, Session variable and Hidden variable. but when i run Response.Redirect method from Gridview_RowCommand, it clear all the Session and Hidden variable values. also tried (Response.Redirect(,false)) method but never got success.

Any suggestion will be appricated in advance.

In UserControl, FooCmdCanExecute (context menu) not called until after a control button is clicked.


I'm seeing an odd behavior I can't explain.  I am using a 3rd party control, and while it's possible it's an issue with that control, I wanted to inquire here to see if anyone has experienced similar behavior in other instances (unrelated to my particular 3rd party control).

I created a UserControl, comprising a ComponentONE chart and several buttons.  When the UserControl is given a data source (for the chart), it programmatically creates a ContextMenu that allows the user to configure the Y view extent for each of the data series provided in the data source.  After it's created, it's set as the ContextMenu for the chart.  The UserControl is used inside a tab on the app's main window, and is also plunked directly inside another window that can be brought up.

The UserControl defines a RoutedCommand - let's say FooCmd.  When the MenuItems for the context menu are created, their Command properties are set to FooCmd.  Also, a CommandBinding in the UserControl associates FooCmdCanExecute() and FooCmdExecuted() in the control class with the command.

The buttons in the UserControl are for data navigation - e.g. , there's one that moves the chart's "viewport" to the beginning of the data, and one for the "end".  The click handlers are not complex - essentially, they just set

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend