Mar 15, 2012, 5:54 PM
[CLOSED] Window created in Code Behind: default Button don´t works
Hi... I´m creating then window in codebehind. Buttons too.
I set in button.listner.click.handler the code to be executed when the button is clicked, as follow.
Follow the sample project:
Main page
I set in button.listner.click.handler the code to be executed when the button is clicked, as follow.
successHandler = String.Format("function (result) {{ if (result) {{ Ext.defer({0}.close, 1, {0}); }}}}", wnd.ClientID)
btn.Listeners.Click.Handler = String.Format("{0}.getBody().{1}({{ success : {2} }});", wnd.ClientID, "Ext.net.DirectMethods.IsVerified", successHandler)
If I click in button, works fine... but when I press key [ENTER], the button Ok is not fired. I´m set de DefaultButton property of window as follow:wnd.DefaultButton = "button[text=Ok]"
I think that the listner (click) that I use is incorrect! There are another listner that I can use?Follow the sample project:
Main page
<%@ Page Language="vb" %>
<%@ 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">
<script runat="server">
Protected Sub AddWindow(sender As Object, evt As Ext.Net.DirectEventArgs)
Dim wnd As Ext.Net.Window
wnd = getWindow()
Me.Form.Controls.Add(wnd)
wnd.Render()
wnd.Show()
End Sub
Protected Function getWindow(Optional url As String = "~/test30.aspx", Optional pTitle As String = "test", Optional iconUrl As String = "") As Ext.Net.Window
Dim wnd As New Ext.Net.Window
Dim loader As New Ext.Net.ComponentLoader
Dim btn As Ext.Net.Button
Dim successHandler As String
loader.Url = url
loader.Mode = Ext.Net.LoadMode.Frame
loader.LoadMask.ShowMask = True
loader.LoadMask.Msg = "Carregando..."
wnd.ID = "window_" & (New System.Random).Next(Integer.MaxValue).ToString
wnd.Title = pTitle
If iconUrl <> "" Then
Else
wnd.Icon = Ext.Net.Icon.ApplicationForm
End If
wnd.AutoRender = False
wnd.Collapsible = False
wnd.Hidden = True
wnd.AutoRender = False
wnd.Maximizable = False
wnd.Loader = loader
wnd.CloseAction = CloseAction.Destroy
wnd.Width = 500
wnd.Height = 400
btn = New Ext.Net.Button
btn.ID = "btnOk" & (New System.Random).Next(Integer.MaxValue).ToString
btn.Text = "Ok"
btn.TextAlign = ButtonTextAlign.Center
btn.Icon = Icon.Accept
successHandler = String.Format("function (result) {{ if (result) {{ Ext.defer({0}.close, 1, {0}); }}}}", wnd.ClientID)
btn.Listeners.Click.Handler = String.Format("{0}.getBody().{1}({{ success : {2} }});", wnd.ClientID, "Ext.net.DirectMethods.IsVerified", successHandler)
'btn.OnClientClick = wnd.ClientID & ".getBody().Ext.net.DirectMethods.Save();"
wnd.Buttons.Add(btn)
btn = New Ext.Net.Button
btn.ID = "btnCancel" & (New System.Random).Next(Integer.MaxValue).ToString
btn.Text = "Cancel"
btn.TextAlign = ButtonTextAlign.Center
btn.Icon = Icon.Cancel
btn.Listeners.Click.Handler = wnd.ClientID & ".close();"
wnd.Buttons.Add(btn)
wnd.DefaultButton = "button[text=Ok]"
Return wnd
End Function
<DirectMethod()>
Public Sub ShowMessage()
Dim mb As New Ext.Net.MessageBox
mb.Alert("Parent alert!", "This messages is triggered in parent!").Show()
End Sub
<DirectMethod()>
Public Sub ShowWindow()
Dim wnd As Ext.Net.Window
wnd = getWindow("~/test25.aspx")
Me.Form.Controls.Add(wnd)
wnd.Render()
wnd.Show()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="resManagerSGCO" runat="server"/>
<form id="form1" runat="server">
<div>
<ext:Button runat="server" ID="btnCreateWindow" Text="Create and Show Window" OnDirectClick="addWindow" />
</div>
</form>
</body>
</html>
<%@ Page Language="vb" %>
<%@ 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">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
txtDescription.Focus(True, 50)
End Sub
<DirectMethod()>
Public Function IsVerified() As Boolean
Return True
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="resManagerSGCO" runat="server" />
<form id="form1" runat="server">
<ext:TextField runat="server" ID="txtDescription" FieldLabel="Description" Text = "" />
</form>
</body>
</html>
Last edited by Daniil; Mar 16, 2012 at 11:44 AM.
Reason: [CLOSED]