Bug In VS2008

L

Lars

Hi

I fear that I have stumbled on to a bug in VS2008. I have controlls added to
a page that is within a MasterPage and when I try to access the controls
from the .cs file the compiler doesn't recognize the control members.

I have this in my aspx file.

<asp:LoginView ID="lvMP3URL" runat="server">

<LoggedInTemplate>

<asp:FormView ID="fvMP3URL" runat="server" AllowPaging="True"
BackColor="White"
BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
CellPadding="3"
CellSpacing="1" DataKeyNames="URL" DataSourceID="sdsMP3Files">
<FooterStyle BackColor="#B4B4B4" ForeColor="Black" />
<RowStyle BackColor="#B4B4B4" ForeColor="Black" />
<EmptyDataRowStyle BackColor="#B4B4B4" ForeColor="Black" />
<InsertRowStyle BackColor="#B4B4B4" ForeColor="Black" />
<RowStyle BackColor="#B4B4B4" ForeColor="Black" />
<PagerStyle BackColor="#B4B4B4" ForeColor="Black" />

<!--Mmore defines
..
..
..
-->

</asp:FormView>
<asp:GridView ID="gvMP3URL" runat="server" AllowPaging="True"
AllowSorting="True" BackColor="White" BorderColor="White"
BorderStyle="Ridge"
BorderWidth="2px" CellPadding="3" CellSpacing="1"
DataSourceID="sdsMP3Files"
GridLines="None">
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
</Columns>
<PagerStyle BackColor="#B4B4B4" Font-Bold="True" ForeColor="Black"
HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#B4B4B4" Font-Bold="True" ForeColor="Black" />
<HeaderStyle BackColor="#B4B4B4" Font-Bold="True" ForeColor="Black" />
</asp:GridView>

</AnonymousTemplate>

</asp:LoginView>




The following code can't be compiled

protected void gvMP3URL_SelectedIndexChanged(object sender, EventArgs e)
{
fvMP3URL.PageIndex = gvMP3ULR.PageIndex;
}

I get the error2

Error 49 The name 'fvMP3URL' does not exist in the current context
Error 50 The name 'gvMP3ULR' does not exist in the current context


Can some one explain why?


Lars
 
L

Lars

BTW

I have tried without the LoginView I still get the same error. The Controlls
in the other aspx files can be reached from its cs file.

Lars
 
G

George Ter-Saakov

It's quite understandable that those controls are not accessible from
runtime..

It's exactly the same as if you have UserControl that has txtInputBox on a
page and then be surprised that you do not have access to txtInputBox from
the page level..


VS 2008 (and .NET) does not know how LoginView control work. It might work
as datagrid for example and multiple the LoggedInTemplate thousand time....
then what???

Your soulution would be to use FindControl...

George.
 
L

Lars

Hi


Tried the following but it didn't work. Took a look at
http://msdn2.microsoft.com/sv-se/library/31hxzsdw(en-us).aspx

protected void gvMP3URL_SelectedIndexChanged(object sender, EventArgs e)
{
LinkButton LB;
FormView FV;
GridView GV;

LB = sender as LinkButton;
if (LB != null)
{
// The name of the controlls was Copies and paisted!
FV = (FormView) LB.Parent.FindControl("FormView1");
GV = (GridView) LB.Parent.FindControl("gvMP3URL");
if ((FV != null) && (GV != null))
{
FV.PageIndex = GV.PageIndex;
}
else
{
Label1.Text = "Could not find fvMP3URL or gvMP3URL";
}
}
else
{
// This is what is the line I reach.
Label1.Text = "Could not identify sender as LinkButton";
}
}



Tanks George.
Lars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top