capturing raddock unique ID from webusercontrol

2 posts, 0 answers
  1. martin
    martin avatar
    4 posts
    Member since:
    Mar 2008

    Posted 14 Jul 2008 Link to this post

    I have a number of rad docks on a portal page, each of the docks contain a WebUserControl. Each of these controls are configurable by the end user.

    one example is a user adds a rss feed control and they then choose the geographical location of the news they want the feed to show. The user can add multiple rss feed control to the portal page each with different settings. I need a way if capturing the uniqueid of each control so I can retrieve the correct configurations setting form the database.

    any examples n vb.net please

    thanks
  2. Kevin Babcock
    Kevin Babcock avatar
    189 posts
    Member since:
    Mar 2007

    Posted 14 Jul 2008 Link to this post

    Hello Martin,

    Have you tried accessing the control's ClientID property to save the client id? I'm not sure of your exact implementation, but if you want to save a user's settings in a user control after the user saves them, you might give this a try. Bubble the Click event from the user control to the page along with any data you want to be able to access there. Add an event handler to handle the event and save the settings and control information to your database.

    In this example I created a simple form which allows a user to input numeric values. I have bubble up the Click event of the Button to the page and made accessible the value the user entered in a custom object which inherits from the EventArgs object. When handling the event at the page level, I now have access to the ClientID property of the user control and the data entered by the user.

    1 <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 
    2  
    3 <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    4  
    5 <%@ Register src="NumericInputForm.ascx" tagname="NumericInputForm" tagprefix="usercontrol" %> 
    6  
    7 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    8  
    9 <html xmlns="http://www.w3.org/1999/xhtml"
    10 <head runat="server"
    11     <title>Untitled Page</title> 
    12 </head> 
    13 <body> 
    14     <form id="form1" runat="server"
    15         <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
    16          
    17         <usercontrol:NumericInputForm ID="NumericInputForm1" runat="server"  
    18             OnClick="NumericInputForm1_Click" /> 
    19     </form> 
    20 </body> 
    21 </html> 
    22  

    1  
    2 Partial Class _Default 
    3     Inherits System.Web.UI.Page 
    4  
    5     Protected Sub NumericInputForm1_Click(ByVal sender As ObjectByVal e As NumericInputFormEventArgs) 
    6         Dim clientID As String = NumericInputForm1.ClientID 
    7  
    8         ' Remaining logic goes here... 
    9  
    10     End Sub 
    11 End Class 
    12  

    1 <%@ Control Language="VB" AutoEventWireup="false" CodeFile="NumericInputForm.ascx.vb" Inherits="NumericInputForm" %> 
    2 <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    3  
    4 <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" /> 
    5 <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" /> 

    1  
    2 Partial Class NumericInputForm 
    3     Inherits System.Web.UI.UserControl 
    4  
    5     Public Event Click As System.EventHandler(Of NumericInputFormEventArgs) 
    6  
    7     Public Sub OnClick(ByVal sender As ObjectByVal e As NumericInputFormEventArgs) 
    8         RaiseEvent Click(sender, e) 
    9     End Sub 
    10  
    11     Protected Sub Button1_Click(ByVal sender As ObjectByVal e As EventArgs) 
    12         Dim eventArgs As New NumericInputFormEventArgs(RadNumericTextBox1.Value) 
    13         OnClick(sender, eventArgs) 
    14     End Sub 
    15 End Class 
    16  

    1 Imports Microsoft.VisualBasic 
    2 Imports System 
    3  
    4 Public Class NumericInputFormEventArgs 
    5     Inherits EventArgs 
    6  
    7     Private _Value As String 
    8     Public Property Value() As Double
    9         Get 
    10             Return _Value 
    11         End Get 
    12         Set(ByVal Value As Double?) 
    13             _Value = Value 
    14         End Set 
    15     End Property 
    16  
    17  
    18     Public Sub New(ByVal Value As Double?) 
    19         Me.Value = Value 
    20     End Sub 
    21 End Class 
    22  

    I know this example may not be exactly what you wanted to do, but hopefully it will help point you in the right direction. Please let me know if you continue to have trouble.

    Sincerely,
    Kevin Babcock
Back to Top