|
-
Apr 16th, 2013, 10:31 AM
#1
Thread Starter
PowerPoster
Server control not accessible in code-behind?
I have a web page that I am converting from classic ASP to ASP.Net. There are a bunch of "Select" controls (DropDown Boxes) that I am changing to DropDownList controls. I have set the "runat='server'" in all of these controls. However, when I go to the code-behind, they are not visible/accessible. I have tried to "clean" the solution and rebuild it and the controls still won't show. Any ideas?
Thanks,
Last edited by blakemckenna; Apr 16th, 2013 at 11:41 AM.
Blake
-
Apr 16th, 2013, 11:59 AM
#2
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
Does anyone have any ideas on this? I'm really under the gun here and need to get this project finished. Sorry for the nagging!
-
Apr 16th, 2013, 12:59 PM
#3
Hyperactive Member
Re: Server control not accessible in code-behind?
is autopostback = "true" in that line somewhere?
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 16th, 2013, 01:25 PM
#4
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
No, the autopostback = true isn't in the declaration of the control and I don't want it to be an autopostback either.
-
Apr 16th, 2013, 01:35 PM
#5
Hyperactive Member
Re: Server control not accessible in code-behind?
without post back certain controls will not fire the event. do you have autoeventwireup set to true?
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 16th, 2013, 01:40 PM
#6
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
No I don't have autoeventwireup = true....
-
Apr 16th, 2013, 01:57 PM
#7
Hyperactive Member
Re: Server control not accessible in code-behind?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Myform" %>
should be at the top of your ASPX file. Try that.
also declare your event signature in the control layout, so for a text box OnTextChanged="EventYouDefined"
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 16th, 2013, 03:02 PM
#8
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
Unfortunately that did not make a difference!
-
Apr 16th, 2013, 03:10 PM
#9
Hyperactive Member
Re: Server control not accessible in code-behind?
DDL has to be marked as autopostback = true to fire the selected index changed event.
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 16th, 2013, 03:13 PM
#10
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
Let me try that and see what that does!
-
Apr 16th, 2013, 03:36 PM
#11
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
That did not affect it either.
-
Apr 16th, 2013, 06:19 PM
#12
Re: Server control not accessible in code-behind?
Not showing a runat server control may occur if you are running C# and VS2008. Is it possible that you have this combination?
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Apr 16th, 2013, 06:32 PM
#13
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
when you say running C#...are you referring to that being the development language that I am using for this particular project? If so, I'm using VB.Net. But I am using VS 2008.
-
Apr 17th, 2013, 11:31 AM
#14
Hyperactive Member
Re: Server control not accessible in code-behind?
language should not matter to the HTML, i just happen to write this one in C# is all.
can you post the offending markup for the control??
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 17th, 2013, 11:34 AM
#15
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
Here is the markup for the just one of the controls. There are a handful of others just like it.
Code:
<asp:DropDownList ID="drpClient" runat="server" style="width: 260px">
<asp:ListItem Value="0">--- Select Client ---</asp:ListItem>
</asp:DropDownList>
-
Apr 17th, 2013, 11:38 AM
#16
Hyperactive Member
Re: Server control not accessible in code-behind?
Code:
<asp:DropDownList ID="ddlCheckType" runat="server" Width="132px" OnSelectedIndexChanged="ddlCheckType_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList>
this declaration workes in 12, should work in 08 too, i just declare my list items values in code instead of markup, but that part dont matter.
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 17th, 2013, 11:40 AM
#17
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
I showed this code to another one of our developers and he added it to his code and tried accessing it in the code-behind and didn't have any trouble. He did some inquiring and the census was that it appears to be a setting within VS 2008. I submitted a ticket to Experts-Exchange as well.
-
Apr 17th, 2013, 11:41 AM
#18
Hyperactive Member
Re: Server control not accessible in code-behind?
that could be...generally you print out the code due for upgrading and rewrite it. upgrading from classic to .net would involve more headaches than just redoing the whole thing.
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 17th, 2013, 08:12 PM
#19
Re: Server control not accessible in code-behind?
Do you have the latest service pack installed?
Also if you add a dropdownlist, go to the designers mode and double click at it, what happens?
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Apr 17th, 2013, 10:42 PM
#20
Thread Starter
PowerPoster
Re: Server control not accessible in code-behind?
I actually just went into the designer.vb of the page and manually inserted the controls. It didn't take to long. I will try what you suggested Sapator just to see what happens.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|