PDA

View Full Version : [CLOSED] I get error when creating (in codebehind) two windows in same page.



supera
Mar 14, 2012, 10:01 PM
Hi!

I get error when creating (in codebehind) two windows in same main page...
The window ID are diferents...

Follow sample project.



<%@ 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">

<DirectMethod()>
Public Sub AddWindow2()
Dim wnd As Ext.Net.Window
wnd = getWindow("~/test28.aspx", "test28")
Me.Form.Controls.Add(wnd)
wnd.Render()
wnd.Show()
End Sub

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 = "~/test27.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"
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.OnClientClick = String.Format("{0}.getBody().{1}({{ success : {2} }});", wnd.ClientID, "Ext.net.DirectMethods.Save", successHandler)

'btn.OnClientClick = wnd.ClientID & ".getBody().Ext.net.DirectMethods.Save();"
wnd.Buttons.Add(btn)

btn = New Ext.Net.Button
btn.ID = "btnCancel"
btn.Text = "Cancel"
btn.TextAlign = ButtonTextAlign.Center
btn.Icon = Icon.Cancel
btn.OnClientClick = wnd.ClientID & ".close();"
wnd.Buttons.Add(btn)

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 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">

<DirectMethod()>
Public Function Save() As Boolean
Response.Write("Save triggered!!!")
Return True
End Function

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="resManagerSGCO" runat="server" />
<form id="form1" runat="server">
<ext:Button runat="server" ID="btnCreateWindow" Text="Create and Show Second Window" OnClientClick="parent.Ext.net.DirectMethods.AddWindow2();" />
</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">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="resManagerSGCO" runat="server" />
<form id="form1" runat="server">

</form>
</body>
</html>

Daniil
Mar 14, 2012, 10:24 PM
Hi,

Any details about the error?

supera
Mar 15, 2012, 12:25 PM
Hi Danill!

The errors does not occurs to you?

Well... The first 'alert' that anything does not right is the button 'Ok' of second window (test28). The text of this button is unaligned.
3942

If I click in 'Cancel' button of second window (test28) to close the window, when the focus move to first window (test27) the buttons of this window are blank
3944

and this errors occurs:
3943

The two windows are created in codebehind, in Test26.aspx page...
I tested with I.E 9.0.8112.16421, but the error occurs in FireFox too...
I have the DP1 version...

Vladimir
Mar 15, 2012, 12:33 PM
Hi,

I didnot test your sample but i see that you use the same IDs for buttons in both windows. Therefore ids conflict is presented on the client side.
Please ensure that all widgets have unique id (or don't define id, unique id will be generated autiomatically)

Daniil
Mar 15, 2012, 12:36 PM
The errors does not occurs to you?

Well, with the details about the errors I will, at least, know what I should reproduce.

On the other hand, sometimes it's not required for us to reproduce the error since we can answer immediately pointing out where the problem might lay. So, it might economy your and our time.


I have the DP1 version...

What do you think about updating to the last sources?

Generally, we can't support DP1 anymore and should concentrate on the bug fixing of the Beta release.

supera
Mar 15, 2012, 12:47 PM
Hi Daniil!



What do you think about updating to the last sources?


I update yesterday from sources of SVN, but had to go back... Some things were working fine stopped working with the last SVN sources.
I decided to go back and wait for the DP2 to not overload you with problems that will probably come out next changelog.

What do you think? I will update the version and going over the problems? I even prefer! Or with the DP2 will see a new changelog?

Daniil
Mar 15, 2012, 12:56 PM
What do you think? I will update the version and going over the problems? I even prefer! Or with the DP2 will see a new changelog?

Well, we update CHANGELOG on the fly as far as we find new changes. There is no plan to make a separate CHANGELOG for DP1/Beta differences.


I update yesterday from sources of SVN, but had to go back... Some things were working fine stopped working with the last SVN sources.

Well, it's sadly, but inevitably at this stage.

Personally, I would prefer to update even if some functionality will be broken.

And, finally, your bug reports are the great help for us!


I decided to go back and wait for the DP2 to not overload you with problems

We are always glad to help and investigate a problem.

supera
Mar 15, 2012, 12:57 PM
Hi Vladimir...

You are right! If I set the ID property this way, works fine:


btn.ID = "btnOk" & (New System.Random).Next(Integer.MaxValue).ToString


Thanks a lot...

Could you explain a little better about these IDs in client-side?
I generate different IDs for windows. I thought that I generate different ID for the window would be sufficient, since the button is contained in the window. This is not the behavior?

supera
Mar 15, 2012, 1:06 PM
Hi Daniil!

Thanks for your conjectures. I think is better remove the bandage quickly.
I'll update. Not a big problem for small changes necessary.
The ext.net 2.x is an excellent set of components and we are very pleased with the results.

Thanks a lot