Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Failure to locate control using Cassini service
robd
#1 Posted : Wednesday, August 15, 2007 9:35:52 AM(UTC)
Groups: Member
Joined: 8/15/2007(UTC)
Posts: 5
Location: North Worcestershire

Hi,

New user first post...

I have an application running vb.net.
The snippets of code below work when tested within Visual Web Developer 2005 Express.
They work when I debug using Cassini as the target server.
But when I run under the Cassini service the postback fails to find the control _owner.

At run time Panel1 has a number of new panels added to it that the postback code then loops round. But since "_owner" is not found all the code is bypassed.

Can anybody shed any light on the cause of the problem please.

Thanks in advance.


<asp:TableRow>
<asp:TableCell>
<asp:Panel ID="Panel1" runat="server" EnableViewState="true" HorizontalAlign="Center">
</asp:Panel>
</asp:TableCell>
</asp:TableRow>

VB setup snippet

Dim ownerPanel As Panel = New Panel()
ownerPanel.HorizontalAlign = HorizontalAlign.Center
ownerPanel.ID = "_owner"
...
...
...
ownerPanel.ScrollBars = ScrollBars.Auto
Panel1.Controls.Add(ownerPanel)


Then on postback

Dim ownerPanel As Panel = Panel1.FindControl("_owner")
If Not ownerPanel Is Nothing Then
For p As Integer = 0 To ownerPanel.Controls.Count - 1
...
... etc


.NET Framework V 2.0.50727
Cassini 2.0.8
Ultidev Team
#2 Posted : Wednesday, August 15, 2007 9:44:57 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi,

we can't think of anything that would cause a difference between in behavior between WebDev server and our Cassini - in the end VB.NET code is executed by the ASP.NET, not the web server.

It seems you are creating "_owner" panel programmatically instead of using ASPX for that, in which case it is not quite clear how the "Panel1" is related to the VB code you presented - there seems to be nothing linking the two. Is there something missing here? What is the role of the "Panel1"?

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
robd
#3 Posted : Wednesday, August 15, 2007 10:10:25 AM(UTC)
Groups: Member
Joined: 8/15/2007(UTC)
Posts: 5
Location: North Worcestershire

Hi,

Thanks for the quick response.

Panel1 is as defined in the Asp snippet.

The page is initially displayed and data selected from a dropdown box. the data related to that dropdown value is then displayed. This is accomplished by adding further panels to panel1, the first of which has an id of _owner. Subsequent data is then displayed within these giving a set of nested panel:

Panel1 contains _owner which in turn contains pan0, pan1,pan2 etc. The number of final panels is data based hence the programmatic generation rather than through aspx.

Panel1 is therefore just the aspx defined home for the programmatically generated controls.

As part of my attempt to ascertain what was going on I inserted the following code

Dim message As String = "Controls in panel1 = " + Panel1.Controls.Count.ToString + vbCrLf
For x As Integer = 0 To Panel1.Controls.Count - 1
message = message + "Control_" + x.ToString + " ID=" + Panel1.Controls(x).ID + vbCrLf
For y As Integer = 0 To Panel1.Controls(x).Controls.Count - 1
message = message + "Sub_Control_" + y.ToString + " ID=" + Panel1.Controls(x).Controls(y).ID + vbCrLf
Next
Next
MessageLb2.Text = message

the result of which was:
Controls in panel1 = 1 Control_0 ID=

Implying that the control is there but has lost its ID as well any child controls.

This failure is happening in FireFox and IE7

Rob
Ultidev Team
#4 Posted : Wednesday, August 15, 2007 10:20:07 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Ok, it makes sense.

Could you please let us know in which event handler (Load, Init) you are executing "Dim ownerPanel As Panel = New Panel() : ownerPanel.ID = "_owner"" child panel creation code? If you do it on page load, then it may be too late. It has to be in the Init handler.

Best regards,
UltiDev Team.

Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
robd
#5 Posted : Wednesday, August 15, 2007 10:35:33 AM(UTC)
Groups: Member
Joined: 8/15/2007(UTC)
Posts: 5
Location: North Worcestershire



Page_Init if page is postback

Button1_Click

Button2_Click

Each of the above call the sub routine that populates Panel1.

Button1 is used after the dropdown item has been selected this results in the data being populated for editing.
When ready button2 is pressed to apply the updates. It is at the start of button2_click that the Postback code is executed - and fails. When it works the database is updated, Panel1 is cleared and re-populated with the refreshed data.

Not quite sure why it is in the page_init - I can never remember the sequence that these things get called.

Rob
Ultidev Team
#6 Posted : Wednesday, August 15, 2007 11:09:24 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Rob,

We probably won't be able to give you definitive answer as to what is going wrong, but you may have a problem with the timing. Just FYI, all the controls defined in the ASPX code are created at the page_Init time, regardless whether it is a postback or not. All the property values defined in the ASPX code get set at the same time, and then control's state gets updated based on what's in the viewstate if it was a postback. Calling the same code from page-init and button_click does not seem right, because button-click follows page_init. Dynamic control instantiation is a tricky thing... Understanding sequence of page rendering events may be crucial to making your code work right.

Bets regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
robd
#7 Posted : Wednesday, August 15, 2007 1:19:52 PM(UTC)
Groups: Member
Joined: 8/15/2007(UTC)
Posts: 5
Location: North Worcestershire

Ok thanks for that. I will have a play tomorrow.
Rob
robd
#8 Posted : Monday, August 20, 2007 11:17:13 AM(UTC)
Groups: Member
Joined: 8/15/2007(UTC)
Posts: 5
Location: North Worcestershire

Hi,

Ok had a play and no joy at all. I also found that a standard grid view was failing to move to the second page - returning no grid when next page was requested.

I compared the page source between the Cassini server version that was not working to the .net app version that was.

The good version had the following bit of code

</style>

<script language='javascript' src='http://127.0.0.1:1025/js.cgi?caw&r=6038'></script>

</head>

The Cassini service version di not have the <script line.

This got me thinking as to whether it was to do with the 127.0.0.1 ip. A search found http://ultidev.com/Forum...aspx?g=posts&t=262.

So I tried using the PC name instead of localhost ie

http://robspc/Birds/Birds_list.aspx

Instead of
http://localhost/Birds/Birds_list.aspx

This has corrected the gridview problem - paging now works.

I have not had a chance to test the original problem - and holidays now beckon.

This result - to date - may mean more to you than I...

Rob
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.