INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

system.web.ui.control._page' is not accessible in this context because it is 'friend'

system.web.ui.control._page' is not accessible in this context because it is 'friend'

system.web.ui.control._page' is not accessible in this context because it is 'friend'

(OP)

I have a procedure "Protected Sub BtnDimSubmit_Click(sender As Object, e As EventArgs) Handles BtnDimSubmit.Click"

In my immediate window I can view the sender information

"?DirectCast(DirectCast(sender,System.Web.UI.WebControls.Button)._page,ASP.quotes_aspx).DDLcontainer2.SelectedValue"
The value returned is ("DRM") which is correct.

I need to test the value at run time however when I try to use the "DirectCast(DirectCast(sender,System.Web.UI.WebControls.Button)._page,ASP.quotes_aspx).DDLcontainer2.SelectedValue"

I get an error before I even run it stating " 'system.web.ui.control._page' is not accessible in this context because it is 'friend' "
I've tried assigning the statement to a string and object with no luck.

Any Ideas

Thanks

-dan

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

I have to ask why you are writing code like this. What exactly are you trying to do?:

CODE

"DirectCast(DirectCast(sender,System.Web.UI.WebControls.Button)._page,ASP.quotes_aspx).DDLcontainer2.SelectedValue" 

Are you in a user control and trying to get the button that caused a postback from the page?

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

(OP)
Hi JB

I have a ajax popup modal extender opening an panel containing an ascx control.
folks enter data in 3 TB's Length, Width, height.
They next press the submit button on the ascx control firing the procedure
"Protected Sub BtnDimSubmit_Click(sender As Object, e As EventArgs) Handles BtnDimSubmit.Click"

In this procedure I was trying to see in the sender what the control on the parent form ( a DDL) value was to handle in a IF clause.
I put a break point in the Sub and was looking at the sender object to determine which control passes the value in.

I put my hover over the sender object and pass down until I saw this

"DirectCast(DirectCast(sender,System.Web.UI.WebControls.Button)._page,ASP.quotes_aspx).DDLcontainer2.SelectedValue"

I dropped it into immediate window. and it shows the value as ("DRM") .

In short Im trying to read the passed in value from the parent form.

Hope this Helps







RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

So now I think I am even more confused. Let me see if I have this.
You have a page with a ddl called DDLContainer2. When a user changes the value you open up a model dialog with a user control in it.
When the user clicks the submit button on the usercontrol, you want to get the selected value in DDLcontainer2.

Is that correct?

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

(OP)
Actually the user selects a value from a dropdown list. Then user clicks a button near it (buttons are ID 1 - 5) which opens the popup modal extender (also number 1-5) containing the three text boxes which the fill in. On the open modal popup user clicks the submit button. When user clicks the submit button on the modal popup I want to read the value of the Dropdownlist that associates with the button.





RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

Ok, much clearer now.
There are 2 ways I can see doing this.

1.)Pass the ddl value as a query string value when you open the modal dialog and have the user control read it.

2.)Create a property on the user control. When the user clicks the button(1 - 5) set the property on the user control with the ddl value.(This is the way I would do it)

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

(OP)
Thanks,

I like option #2. Can you nudge me in the right direction on setting a usercontrol proerty?

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

You just create a property on the user control like you would on a page:

CODE

public property ddlValue as string 

Register your user control on the page:

CODE

<%@ Register Src="~/relative path to your usercontrol/yourUserControl.ascx" TagName="ucMyUC" TagPrefix="uc1" %> 

Place the user control on the page

CODE

<uc1:ucMyUC ID="ucMyUserControl" runat="server"></uc1:ucMyUC> 

Set the property on the user control from whatever event you need:

CODE

ucMyUserControl.ddlValue = DDLcontainer2.SelectedValue 

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

(OP)
Ok Thank you very much. I'll give it whirl here in a little while. I'm juggling a few things and that one hasn't come back down yet :)

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

(OP)
jbenson001

Had to do a change up. Seems I'm going to call the same control from other pages.
What I wound up doing with the popup modals button click event was...

If parent.ID = ("BlaBlah") then
DDLvalue = CType(Parent.FindControl("DDLcontainer1"), DropDownList).SelectedValue


end if


Just posting this in case somebody else runs into my dilemma.

Thanks Again. :)

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

You are not implementing the code I sent you. Do not set the value of the property in the user control code behind. You set the user control's property from the page's code behind that it is on.

The purpose of a user control is so that it can be reused on multiple pages. What you are doing is tying to the page, which you don't want to do.
Again, in the page's code behind:

CODE

maybe put this in the ddl's selectedindexchanged event ON the PAGE
ucMyUserControl.ddlValue = DDLcontainer2.SelectedValue 

Let me know if you have quesitons.

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

(OP)
jbenson001

The selectedundexchange and although I wasnt using that even I can use it.
What's bugging me is I had tried you first option (#2) above.

I registerd the UC ("FgtDimensions.ascx") on my page "Quotes.aspx"

<%@ Register Src="~/FgtDimensions.ascx" TagPrefix="uc1" TagName="FgtDimensions" %>

I have the control ID set in the modal Popup extender firing off of my "BTNdims1" button.

<uc1:FgtDimensions runat="server" ID="FgtDimensions1" />

I've created the value "Public DDLval1 as String" on my UC.

But my intellisense will not display "FgtDimensions1" so I can't assign FgtDimensions1.DDLval = DDLcontainer1.SelectedValue .

I think I missed something along the way :(




RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

Possibly the definition of the UC on the page

CODE

<uc1:FgtDimensions runat="server" ID="FgtDimensions1" /> 
try changing to

CODE

<uc1:FgtDimensions runat="server" ID="FgtDimensions1" /></uc1:FgtDimensions> 

also make sure the property on the UC is Public

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

(OP)
Tried it but it didn't help.

Here's the script on the 1st button.

<asp:UpdatePanel ID="UPpnlDims1" runat="server">
<ContentTemplate>
<asp:Button ID="BtnDims1" runat="server" Text="Dim" Width="31px" Font-Size="XX-Small" ToolTip="Enter Dimensional Load Information" TabIndex="11" style="height: 21px" />
<ajax:ModalPopupExtender ID="BtnDims1_Mpe" runat="server" Enabled="True" TargetControlID="BtnDims1" PopupControlID="PNLfgtDimension1" DropShadow="true">
</ajax:ModalPopupExtender>
<asp:Panel ID="PNLfgtDimension1" Style="display: none;" runat="server" BorderColor="#212020" BorderStyle="Double" Visible="true" BorderWidth="6px" Width="440px" Height="150px" BackColor="White">
<uc1:FgtDimensions runat="server" ID="FgtDimensions1"/>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnDims1" />
</Triggers>
</asp:UpdatePanel>

RE: system.web.ui.control._page' is not accessible in this context because it is 'friend'

You should be able to make the code I gave you work. I don't know if any of those AJAX controls are interfering somehow. I don't use them. I use JQuery and JQuery UI.
I don't think they should do anything. You need to check syntax and the registration of the UC again.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close