This is a migrated thread and some comments may be shown as answers.

capturing raddock unique ID from webusercontrol

1 Answer 60 Views
Dock
This is a migrated thread and some comments may be shown as answers.
martin
Top achievements
Rank 1
martin asked on 14 Jul 2008, 12:29 PM
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

1 Answer, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 14 Jul 2008, 04:06 PM
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.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<%@ Register src="NumericInputForm.ascx" tagname="NumericInputForm" tagprefix="usercontrol" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
         
        <usercontrol:NumericInputForm ID="NumericInputForm1" runat="server"  
            OnClick="NumericInputForm1_Click" /> 
    </form> 
</body> 
</html> 
 

 
Partial Class _Default 
    Inherits System.Web.UI.Page 
 
    Protected Sub NumericInputForm1_Click(ByVal sender As ObjectByVal e As NumericInputFormEventArgs) 
        Dim clientID As String = NumericInputForm1.ClientID 
 
        ' Remaining logic goes here... 
 
    End Sub 
End Class 
 

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

 
Partial Class NumericInputForm 
    Inherits System.Web.UI.UserControl 
 
    Public Event Click As System.EventHandler(Of NumericInputFormEventArgs) 
 
    Public Sub OnClick(ByVal sender As ObjectByVal e As NumericInputFormEventArgs) 
        RaiseEvent Click(sender, e) 
    End Sub 
 
    Protected Sub Button1_Click(ByVal sender As ObjectByVal e As EventArgs) 
        Dim eventArgs As New NumericInputFormEventArgs(RadNumericTextBox1.Value) 
        OnClick(sender, eventArgs) 
    End Sub 
End Class 
 

Imports Microsoft.VisualBasic 
Imports System 
 
Public Class NumericInputFormEventArgs 
    Inherits EventArgs 
 
    Private _Value As String 
    Public Property Value() As Double
        Get 
            Return _Value 
        End Get 
        Set(ByVal Value As Double?) 
            _Value = Value 
        End Set 
    End Property 
 
 
    Public Sub New(ByVal Value As Double?) 
        Me.Value = Value 
    End Sub 
End Class 
 

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
Tags
Dock
Asked by
martin
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Share this question
or