C# - Adding X:Name To A User Control Gives Error In Generated Code Of Page Its Used In?
Oct 22, 2010
I am basically using a user control for the first time, so hopefully it's just a dumb mistake.I have a simple user control
<UserControl x:Class="TestProject.WebApp.myUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
[code]....
View 2 Replies
ADVERTISEMENT
Apr 25, 2012
I am trying to use a script mananger to use page methods to communicate between the server and client side of my page. I have added this code to the html
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="True">
When I add this, here is what is inserted into the designer page.
Protected WithEvents ScriptManager1 As Global.System.Web.UI.ScriptManager
But when this is automatically added, i get this error.
Error 52 Type 'System.Web.UI.ScriptManager' is not defined. C:UsersBillDesktopiPlan-7-layerlistingsummarytreeMain.aspx.designer.vb 32 44 iPlan
I added a reference in my project to system.web.services - but still can not seem to get around this error.
View 1 Replies
Feb 12, 2011
I have an asp.net usercontrol which represents a "popup" dialog. Basically, it's a wrapper for the jQuery UI dialog which can be subclassed to easily make dialogs. As part of this control, I need to inject a div into the page the control is used on, either at the very top or very bottom of the form so that when the popup is instantiated, it's parent is changed to this div. This allows "nested" popups without the child popup being trapped inside the parent popup.
The trouble is, I can't find a safe way to inject this div into the page. A usercontrol doesn't have a preinit event, so I can't do it there, and calling Page.Form.Controls.Add(...) in Init, Load or PreRender causes the standard exception "The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases."
I thought I had found a solution by using. ScriptManager.RegisterClientScriptBlock(Page, Me.GetType, UniqueID + "_Dialog_Div", containerDiv, False) which seemed to work well normally, but recently a coworker tried putting an UpdatePanel inside the dialog and now she's getting the error "The script tag registered for type 'ASP.controls_order_viewzips_ascx' and key 'ctl00$ContentBody$OViewZips_Dialog_Div' has invalid characters outside of the script tags: . Only properly formatted script tags can be registered."
How are you supposed to add controls to the pages control collection from inside a user control?
View 2 Replies
Jun 18, 2009
I've got a form with a TabControl. PictureBoxes (containing thumbnails) are added to each TabPage thru a loop. A click event Handler is added for each PictureBox. When a PictureBox is clicked, a new form is created thru code and a PictureBox is added to it that shows the pictures enlarged. What I need is to add another Handler to the PictureBox in the code-generated form so that I can rotate the pictures because some of them (photographs) were taken with the camera at 90 degree angles from vertical. I've tried to come up with a solution but I always run into the problem of the PictureBox on the code-generated form needing to be declared WithEvents before a Handler can be added.
Code for adding PictureBoxes to TabControl:
'Variable p declared public withevents at class level
p = New PictureBox
img = Image.FromFile(Path.GetFullPath(picfile))
[Code].....
View 5 Replies
Mar 27, 2012
In the early generations of VB.NET visual studio, I used to see an automatically generated region named "Windows Form Designer generated code" that includes the code that generates the controls at the surface of a form. But what happened with VS 2008, I can't see that region any more ? Where are the lines of code that are automatically generated that create controls and set there properties ????? Luai Alrantisi, BSc in Computer Engineering, University of Ottawa 2007, Canada. IT Manager of MTN Mobile Telecom.
View 2 Replies
May 6, 2011
I am trying to subclass the password recovery control in asp.net (4) so that I can override the behaviour of the OnVerifyingUser event but I'm having trouble adding my subclassed password recovery control into the page. I tried creating an asp:placeholder control and adding a new instance of my subclassed control to it but I just get an error that says "An entry with the same key already exists". I've tried doing this in the page_init and page_load methods but get the same error.
Here's an example of my subclass
Partial Class MyPasswordReminder
Inherits PasswordRecovery
[code].....
View 2 Replies
Mar 17, 2009
i have created my own custom propertythe property is of type collection ,it displays a form which allow the user to add a list of images and strings,it stores the data in a collection ,my problem is , i have noticed that after adding items to the collection at design time , there is no code generated in the .Designer file of the form and there for when i close the for / save it and reload it , all the items that i added to my custom property are gone.my question , what did i miss here ? how do i make my custom property generate code at the .designer file for the items i have added to my property?
View 1 Replies
Oct 17, 2011
I have an aspx page that has two different user controls. I want to find user control A and be able to set properties, etc., from user control B.
I was thinking I could do something like this:
Dim CMFilters As Control = Me.Parent.FindControl("CMFilters")
...but that doesnt work to be able to set properties and call methods. I somehow need to get the user control and and declare it as that user control type.
View 2 Replies
Apr 27, 2011
I have a user control that checks if a certain query string and session value are present then returns a boolean based on that, if it's true I want to set the master page. The page is throwing an Object reference exception when it tries to call the method EditUser1.UserAuthorization(). Why is this happening? I imagine that the method doesn't exist at that point in the stack. Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
[Code]...
View 1 Replies
Dec 27, 2009
I want to access a page variable from a user control placed on that page. All the solutions work in C# via casting to the page class. The problem is that this doesn't work in VB. The page class is not selectable from the Intellisense dialog. Manual typing results in the error type not defined. It is strange that C# can do this without a problem. What is the proper solution for this in VB? I had other cases where I needed to access a control on the main page. C# again uses a cast to the page class to access the control. This doesn't work in VB again. So how can I access the page class from a user control in generell?
View 5 Replies
Jun 1, 2010
I'm using VS2008 and SQL CE 3.5, building a smart client app. When I add a table adapter with this code:
UPDATE feeders
ET planningAreaID = @areaID
WHERE feeders.transformerID IN
[code].....
View 5 Replies
Sep 9, 2009
I am using ASP.NET with MasterPages. Thus i cant just place this link in my pages that reference my MasterPage.
<link rel="canonical" href="http://www.erate.co.za/" />
I need to place this link in though my Page Load of each one of my pages. How would i do this through code? I am using VB.NET but C# will also help me in the right direction.This is how i did it for my DESCRIPTION tag in my code behind.
Dim tag As HtmlMeta = New HtmlMeta()
tag.Name = "description"
tag.Content = "Find or rate any company in South Africa for FREE and rate them"
Header.Controls.Add(tag)
View 6 Replies
Jun 3, 2009
I have an ASP.NET 3.5 page with some AJAX, some Validators and some business-rule validation done in the code-behind page (VB.NET).
The Validators set focus to the 'offending' control when an error is detected.
When a business rule is violated, I used the following code to generate some javascript "on the fly" and execute it to simulate the Winforms "MessageBox.Show" functionality:
Sub DisplayMessages()
Dim lblError As New Label
lblError.Text = "<script language='javascript'>" & Environment.NewLine & "window.alert('"
[Code]....
At the end of the "btnSave.Click" code, if everything went ok, calling that subroutine.
What I get is the page scrolling to the top and then back to where it was when the Save button was clicked.
For various reasons, 'MaintainScrollPositionOnPostback="True"' is in the Page directives at the top of the .aspx code. What I'd really like is to make that FALSE for just a moment so that the page resets at the top - again, only if everything is ok and only for this button (there are other buttons on the page that require the page to keep it's scroll position).
View 1 Replies
Jan 11, 2012
how to add an icon to a user control - I'm talking about the icon that shows up in the toolbox. I have found some articles on the Microsoft site, but honestly they are so complicated and esoteric that I simply cannot follow them - it's like every synaps in my brain is misfiring when I try to read it!
I would love to see a very simple example of how this should be done.
I've tried embedding the image into the resources, setting the build action to Embedded Resource, creating a ResourceFinder class (as per MS advice) and then preceding the class with:
<ToolboxBitmap(GetType(ResourceFinder), "ExposureMeter.Exposure.bmp")>
.. but so far I feel like I'm shouting into a cave without a single bat flying out...
View 1 Replies
Jun 12, 2011
UserControl Contain two combobox and Gridview Control. When i add this control to my form and change the value of combobox selected item then the value not get into the form But when i debug the code and reevaluate (Quick Watch it) then i get the value of combobox.selecteditem
[Code]
View 3 Replies
May 21, 2009
I have a base page class that inherits from Page. We'll call it SpiffyPage. I also have a user control called SpiffyControl. I then have an aspx page, ViewSpiffyStuff.aspx, that inherits from SpiffyPage. On page load, the SpiffyPage class is supposed to inject a SpiffyControl into the aspx page. The problem is that SpiffyControl is a user control, and to instantiate that in the code behind one has to access the ASP namespace, sort of like: ASP.controls_spiffycontrol_aspx MyControl;
But SpiffyPage isn't an aspx page, it's just a base page, and as such I can't access the ASP namespace, and I therefore can't instantiate a SpiffyControl in order to inject it. How can I achieve my goal?
Edit: One important point is that I must have a reference to the actual control type so I can assign values to certain custom Properties. That's why a function like LoadControl, which returns type Control, won't work in this case.
View 11 Replies
Sep 30, 2009
I am trying to figure out how to declaratively pass in a event handler into a user control, but I am stumped. All I can make work is the user control's event handler.. I can't seem to bubble up the caught event into the parent page. Ideas would be quite welcome. Here is my code:Default.aspx:
<%@ Page Language="VB" %>
<%@ Register TagPrefix="rpt" TagName="filter" Src="WebUserControl.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
[Code]...
View 1 Replies
Nov 4, 2010
Trying to access a property from the parent page on my user control.
Here's the start of my default.asp codebehind:
Partial Class _Default
Inherits System.Web.UI.Page
Private _selectedID As String = "74251BK3232"
[Code].....
I'm getting the error "selectedID is not a member of System.Web.UI.Page"
View 2 Replies
Mar 13, 2009
I have done this the other way many times as it makes sense (the page knows about the control as it has been added to the page and can handle the 'child' event)
Is it possible to do it the other way? I think not as the control doesn't know what page it is going to be on
The reason i ask this is that I have a modal popup on the page to ask users to login, and it is only when the user has logged in that I want my user control to go away and execute some code but I am not too sure how to tell the control this has happend?
View 2 Replies
Apr 7, 2010
i'm trying to learn about user controls. I created a user control that has a textbox and a button. What i'd like to be able to do is when i click the button in the user control, populate a label in the aspx page. I understand that i could just have a button on the page that uses some properties on the user control to get that information.. but i'd like to know how to do it with the button the user control.. the reason for this is the button is just an example.. a learning tool. if i can get this working, i'd likely be putting thing in the user control that might require this kind of passing information. Anyway.. i've found some c# examples that i tried to get working as vb.. but once started getting into the delegates and events..
View 3 Replies
Sep 17, 2010
I'm having trouble finding how to do this, could anyone let me know how this is done via VB code
View 7 Replies
Dec 4, 2009
I have created a user control that mimics what a label does. I realize I could have inherited the label control, but I am working on understanding the process. I wish to add items to the control. normally (in the code of my project) would do:
Form1.Label1.Controls.Add(mylabel)
After creating mylabel in the code of course.
[code]....
View 4 Replies
Oct 23, 2009
There is a response to this question using C# - I am looking for a VB answer and the C# code is too deep for me. I have a custom user control and I have a toolstrip on it. I have certain default buttons on the toolstrip, but I want the user to be able to add additional buttons at design time. I exposed the Toolstrip.Items collection in a public property. I can open the collections editor in design time, but I cannot edit the collection.
View 1 Replies
Mar 8, 2010
I've made a user control and have added some internal labels inside it. In the User control class I'm trying to handle the mouse events so that: When the mouse enters the User-Control the background of the User-Control turns white - using MouseEnter event. When the mouse leaves the User-Control the background of the User-Control turns grey - using MouseLeave event. However as soon as I move the mouse over the internal labels it triggers the MouseLeave event. I don't want it to do that, because the mouse hasn't left the bounds of the User-Control! So, how do I get it to not trigger the MouseLeave event when the mouse is still internal to the User-Control?
View 9 Replies
Dec 13, 2011
I am trying to delete a customer record. In the page I have an usercontrol for address and it has some validation. I cannot delete the record since it fires the validation controls.
View 1 Replies
Jan 15, 2012
Is there any way of hiding the tab page headers without having to create a new user control?
View 2 Replies
Nov 1, 2011
I have an ASP.NET page (WebForm) on which I set the content of a central DIV by dynamically loading one of five user controls during Page_Load, dependant on the stage of the application.
One of the user controls contains radio buttons and a text box together with a submit button. What I want to do is process that information when the form is posted using the submit button.
I could do this with an AJAX call using jQuery, but I don't really want to do that, so I'm trying to access the form data on postback, but on page load following the postback the data is not present in the Request.Form object.
Looking at what I need to do it seems pretty simple and I'm sure is once you've got your head around it, but I can't find out how to carry this out. Some of the things I have read refer to event bubbling, but that doesn't make too much sense in this scenario.
EDIT: To clarify, I want to post the page back to itself to capture the values from the form elements via the Request object, store them in the database, and then display a confirmation message (or something else) on postback, and not re-display the same control again. So I won't be loading the same user control again.
View 3 Replies
Feb 14, 2012
I'm using the following code to add a table to a user control in Umbraco.
Try
Dim DS As DataSet = GetData()
If DS.Tables(0).Rows.Count > 0 Then
[Code]....
But what happens after the loop completes (without errors - I've stepped through the whole thing), the only content left on the page is the table.
View 1 Replies
May 26, 2010
I found that if you press F5 or refress from browser window, the last event fires again
example, I have clicked on a button, the button event is carried out normally, but if I refresh the page by pressing F5 key the same event is fired again.
View 1 Replies
Oct 27, 2010
I have a simple user control which wraps some logic around an AutoCompleteBox. This question could apply to any ItemsControl control like a dropdown or listbox though.
<UserControl>
<Grid Background="White">
<sdk:AutoCompleteBox Name="myACB" ItemsSource="{Binding myData}" />
[code].....
View 2 Replies