May 19, 2010, 4:49 PM
[CLOSED] [1.0] How to access a direct method event inside a user control
Hi,
I need to access the direct method event which is declared inside a user control which is created dynamically inside a window.
This is my scenario,
I am opening a window on clicking a button in the parent page (Sample.aspx). In the window im loading the user control(Sample.ascx). I have got a save button in user control(sample.ascx). Now when i click the save button, i have to call a DirectMethod in the user control (sample.ascx).
This is my sample code.
Sample.aspx:
When i run the application, im getting the error as --Microsoft JScript runtime error: Object doesn't support this property or method..
I also need to know, how to give ID property for the usercontrol which is loaded dynamically inside the window.
Once i give the ID property, then i think i can able to access the method by the following way,
Ext.net.DirectMethods.ID.SaveClick().. Is that correct ?..
I need to access the direct method event which is declared inside a user control which is created dynamically inside a window.
This is my scenario,
I am opening a window on clicking a button in the parent page (Sample.aspx). In the window im loading the user control(Sample.ascx). I have got a save button in user control(sample.ascx). Now when i click the save button, i have to call a DirectMethod in the user control (sample.ascx).
This is my sample code.
Sample.aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Sample.aspx.vb" Inherits="Zangle.NET.Sample" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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 runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<ext:Panel runat="server" Title="Student Search" Border="false" BodyStyle="padding:3px">
<Items>
<ext:Button ID="btnOpen" runat="server" Text="Open">
<DirectEvents>
<Click OnEvent="openButtonClick">
<EventMask ShowMask="true" Msg="Loading..." />
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Panel>
</form>
</body>
</html>
Sample.aspx.vb:Imports Ext.Net
Partial Public Class Sample
Inherits System.Web.UI.Page
''' <summary>
''' Handles the Click event of the StudentFindButton control.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="Ext.Net.DirectEventArgs" /> instance containing the event data.</param>
Protected Sub openButtonClick(ByVal sender As Object, ByVal e As DirectEventArgs)
Dim win As New Ext.Net.Window
win.ID = "StudentEditStatus"
win.Title = "Student Editor"
win.Height = 120
win.Width = 140
win.ContentControls.Add(Me.LoadControl("SampleControl.ascx"))
win.Render(Me.Form)
End Sub
End Class
Sample.ascx:<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="SampleControl.ascx.vb"
Inherits="Zangle.NET.SampleControl" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<ext:Panel runat="server">
<Buttons>
<ext:Button ID="StatusSaveButton" runat="server" Text="Save">
<Listeners>
<Click Handler="Ext.net.DirectMethods.SaveClick();" />
</Listeners>
</ext:Button>
</Buttons>
<Content>
<ext:FormLayout ID="FormLayout1" runat="server" LabelAlign="Left" LabelSeparator="">
<Anchors>
<ext:Anchor>
<ext:TextField ID="TrackTextField" runat="server" FieldLabel="Track*"
Width="200px">
</ext:TextField>
</ext:Anchor>
</Anchors>
</ext:FormLayout>
</Content>
</ext:Panel>
Sample.ascx.vb:
Imports Ext.Net
Partial Public Class SampleControl
Inherits System.Web.UI.UserControl
<DirectMethod()> _
Public Sub SaveClick()
TrackTextField.Text = "Saved"
End Sub
End Class
Could you tell me how to access the SaveClick DirectMethod of the usercontrol..When i run the application, im getting the error as --Microsoft JScript runtime error: Object doesn't support this property or method..
I also need to know, how to give ID property for the usercontrol which is loaded dynamically inside the window.
Once i give the ID property, then i think i can able to access the method by the following way,
Ext.net.DirectMethods.ID.SaveClick().. Is that correct ?..