I am extending the TextBox class to include CustomValidator along with the TextBox. I have created properties like CSSClass for ErrorMessage, CustomErrormessage for ErrorMessage on failure. But I am not sure how to get server side validation method in the form of tag. Example:
<asp:CustomValidator runat="server" id="custPrimeCheck"
ErrorMessage="Invalid Prime Number" />
PrimeNumberCheck is the method name which is passed as parameter, same way I want to pass method in my custom TextBox for CustomValidator to run on server side.
The built in Asp.Net Controls (label, Textbox, etc.) all have a CssClass property that can be set, what do I need to do to implement that for a Web User Control?
I know how to add a property and pass thru the get & set to the corresponding Asp.Net control (example if I have a label I know how to create a LabelCssClass property that provides a get & set, but the control itself how do I set a CssClass or ClassName property.
I am creating a custom control. Let's say I'm reinventing the wheel and creating a custom Button control that derives from the UserControl class(only for example)
Well, it of course has a Click event handler. Now my problem is, when do I call this event handler? I know it happens sometime between the Pages OnLoad and OnLoadComplete, but I'm not quite sure what event I can hookup to so that the Click event is raised at the same time as other control events.
I am trying to create a simple custom control where in there is a image button on the control along with a label.
the problem that i am facing is that the image button appears just fine along with the specified properties. But somehow when i click on the image button it does not generate the click event. the page simply refreshes.
I have a custom control which contains (amongst other things) an imageButton.
I'm adding a handler to the "click" event of the imageButton however when the button is clicked the handler routine is not called. where I am going wrong with this? should I be handling the click event in some other way?
I have developed a User Control in inline code model and convert this into dll and try to add it into Visual Studio ToolBox. It shows error "There is no component found in the object.". It is showing actually because i have not added ToolBoxData attribute just before the class declaration, because there is no class declaration in the inline code model. I don't know where i have to add ToolBoxData attribute.
I have created a custom control which uploaded files to the server . These uploaded files list that is the name of the file and the file path i save in a session and the files i save to a temp directory .
Now, I want to delete these files as well as clear the session when this control is no longer used .How do i find whether the control is no longer used in the page . I should be doing this from the Custom control and not from the Page ?
I have a custom ascx user control on my page that includes a dropdownlist. There is an onSelectedIndexChanged event handler that is connected to this dropdownlist. The first time the user selects a value, the page does a postback and the logic executes correctly. However, if the user then goes to change their selection, the event handler does not get triggered.
I've created a UserControl that is dynamically placed onto my page during the Init event. It populates and works great, but I'm left scratching my head at how to retrieve data from it during a postback.
After selecting an item, the rendered HTML looks something like:
I may be completely off track and this may actually be impossible (or a stupid idea). The only alternative I can think of is to emit actual ASP.NET controls and hook the built-in event handlers.
I have created a Web User Control and convert it into Web Custom Control and add it in Tool Box of Visual Studio. When i drag and drop this web custom control from tool box, i want to execute some sql for that web Control. How do i write a code in Web User Control so that it will execute on drag and drop of Web Custom Control prepared from this Web User Control?
My CompositeControl creates dinamically several RadioButtonLists according to the DataSource information. These controls are added to the Controls list and rendered in CreateChildControls event.
I need to create a LinkButton that clear a specific RadioButtonList selection and do a postback, to load the DataSource information again (some selections changes the data that need to be loaded from the database). For each RadioButtonList, I've put a LinkButton and assigned the Click Event to a method inside the same CompositeControl, to do the RadioButtonList cleaning.
Unfortunatelly, the LinkButton doesn't trigger the Click Event. In HTML code, the link has the "onclick" attribute setted with the asp.net event, but when clicked, nothing happens.
Scenario: I have a Gridview where I want to handle the Sorting in a custom control that I've added to the header. I've added this control to my GridView's Header via OnRowCreate event handling. I want the Sort Expressions to persist session to session (via Webparts Personalization)
Here is what I have for adding the custom header control to the GridView Header
This works out well for adding the control, but I can't get anything to persist because these controls are creating initially via postback (per the event) and re-created on all subsequent postbacks. I can't add an If(!IsPostback) because the controls are initially created on the gridview's postback (well at least thats how it's acting when I put it in there) If I were to add this control via the ASP page, not via the Codebehind, I would be able to persist the control. If I try to treat it as though everything is setup correctly, and assign my custom control's controls to [Personalizable], I get a runtime error telling me that I can only have webpartzones in or before Page_init (I'm guessing this is due to when/where the gridview hits the OnRowCreate event). If there is some fundimental logic I'm missing, or best practices that I'm moving away from,