VS 2008 - Page And A Custom Control On That Page
Sep 7, 2011
I have an asp.net pagel called UserApproval.aspx. On that page is a custom control ascx. So the order of events is that UserApproval's Page_Load is called, then the ascx's Page_Load is called. The ascx page might discover a problem and can't render what it needs to render (if the user isn't authorized). It has no problem hiding some of the web controls on it, but I would also like to hide some of the web controls on the parent/UserApproval page. Am I able to do this?
For example, the parent page displays instructions about clicking a button. But the buttons are built by the custom control if the user is authorized to see the buttons. If he can't, can I change or hide the parent's instructions?
View 7 Replies
Similar Messages:
Jan 25, 2011
I haven't worked on web applications in eight months or so (last contract work was WinForms), and I am trying to remember what I knew about custom controls. My issue is that I am replacing a developer who is gone and there isn't much doc or knowledge on-site anymore regarding at what point his code was left off. So I am figuring it out. We work with 3rd-party software API's. In an extension (a DLL), I am able to test what 3rd-party page is being navigated to and navigate to my own page instead. Let's call this page UserApproval.aspx when its the 3rd-party page, and UserApproval_mmock.aspx when it's mine (really his - the former developer's). The former developer has a line of code in the _mmock page, like so:<%@ Register TagPrefix="mockCustomCtl" TagName="TestControl" Src="~/Folder-1/Controls/MyCustomControl.ascx" %>Nowhere else in the code do I see a reference to mockCustomCtl. Shouldn't I, if the page is indeed rendering this control? Could that be where he left off - he created his own replacement page, created the custom control (I do have the source to MyCustomControl.ascx), but didn't actually put the custom control *on* the page?
View 11 Replies
Dec 20, 2010
created a Custom Textbox Control that is intended to be a "masked date" textbox, so that I can handle different ways a user might enter in a date and make it work no matter what.I did this by creating a custom control with 3 separate Textboxes one for month,one for day one for year,then do some handling for different things that could be entered and it would all work.
The problem I am having is,when I add this control to the page,if I do an alert to check the Text value of the custom control it just gives me "[ServerControl1]" even if I enter in a date.
I tried doing an AutoPostback after entering so that it would refesh the Viewstate to have the values of the textboxes but the control doesnt seem to actually postback, even though I have it enabled.accessing the Textbox value after someoen
has entered a date?first custom control I have created and have been using google.
My Server Control Code is as follows:
[Code]...
View 1 Replies
Oct 22, 2010
I want to create a custom control where I define several specifically named DIV sections. The code-behind logic of the custom control will perform operations on these named DIV sections. The page where the custom control is hosted needs to be able to add named controls to the DIV sections and perform operations on these named controls added to the DIV sections.
Let me explain a little further. In the custom control, I want to have code behind logic that fires the following Page Event and uses a condition to make one or another specifically named DIV section visible or not:
< _
ToolboxData("<{0}:BaseDetails runat=""server""></{0}:BaseDetails>") _
> _
Public Class BaseDetails
[code]...
how can I create a custom control which is able to generate the named DIV sections "DetailsNameDiv1" and "DetailsNameDiv2" where my custom control can check a condition and make one or the other visible. Also, I need to be able to add controls to these named DIV sections when I host the custom control and the control that I add to the named DIV section needs to let me set values of these controls from the code behind logic of the page (or usercontrol) where the custom control is being hosted (in my example, I am adding TextBox controls that I want to set the Text property from a SQL Data Reader).
View 3 Replies
Feb 26, 2010
I am writing an ASP.NET custom control.In my custom control code, I find a PlaceHolder control in the page like so:this.myPlaceholder = Page.FindControl("placeholder1") as PlaceHolder Then, I render the placeholder as the output of the custom control:
protected override void Render(HtmlTextWriter output)
if (this.myPlaceholder != null)
this.myPlaceholder.RenderControl(output);
However, this causes the placeholder to be rendered in two places - in the custom control output (good) and in the original location in the page (bad).
View 1 Replies
Oct 22, 2010
I have to use inline code for an aspx page and I need to use a custom server control that is defined in the same aspx page but the control does not get processed as a server control. it gets returned as is as static html tag.
View 3 Replies
Jan 19, 2010
I have an existing page. I drag a text box control from the tool box onto the page. When I execute the application I get error (this happens to other additional controls as well):
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
At this point I do not have any errors.
Now when I reference the control in the code behind, it gives me error when I execute the application.
If TextBox2.Text = "" Then
mySqlCommand.Parameters.Add(New Data.SqlClient.SqlParameter("@GroupName", Data.SqlDbType.VarChar, 50)).Value = DBNull.Value
Else
mySqlCommand.Parameters.Add(New Data.SqlClient.SqlParameter("@GroupName", Data.SqlDbType.VarChar, 50)).Value = TextBox2.Text
End If
Error2Name 'TextBox2' is not declared.
Error3Name 'TextBox2' is not declared.
View 24 Replies
Feb 17, 2011
I have a content page which has a related master page.I register a prefix <%@ TagPrefix ..... and can load other custom controls at that namespace.However, one particualar control at the same namespace, when added to the aspx page, breaks it.The control in question inherits from asp:Panel, has a parameterless constructor, defines a few public accessors, and creates some standard child controls, and nothing much else.Are there some fundamental restrictions to creating custom asp controls that I am breaking unknowingly?
View 2 Replies
Oct 6, 2010
I have a control I need to hide when loading page. Not sure how to do that in a good way. This is what I have, it very briefly shows the control when page is being loaded then hides it.
Code:
<script type="text/javascript">
window.onload = function() {
document.getElementById("<%=UpdateProgress1.ClientID %>").style.display = 'none';
View 2 Replies
Jan 21, 2010
1) I've page class public partial class MyDelivery : System.Web.UI.Page
2) ASCX is in different subfolder public partial class MyControls_Hello_Bye : System.Web.UI.UserControl
I am unable to access #1 parent page class from control
View 2 Replies
Nov 3, 2010
I have a usercontrol (ascx) that I want to dynamically add to a page.
Neither the control nor the page has a namespace (thanks crappy vendor).
When I use the following, it tells me it cant find the "type or namespace"
StayTunedControl = (UserControler_StayTuned)LoadControl("~/UserControler/StayTuned.ascx");
Page.Controls.Add(StayTunedControl);
StayTunedControl.StayTunedID = Convert.ToInt32(IncludesStayTunedMeta.Value);
After some tweaking to the namespaces, etc, I am now at a point where the 3rd line above generates the following error:
'System.Web.UI.UserControl' does not contain a definition for 'StayTunedID'
I was hoping that casting StayTunedControl as type (UserControler_StayTuned) would fix this.
View 2 Replies
May 24, 2010
We have created a Master page that inherits off the asp.net Master class.We have also got ui controls that inherit off the standard asp.net ui control class.Our Master page has a public member variable. We need to be able to access that member variable from the ui controls that we use.However we can't seem to get at it? Is it our architecture that is wrong? Or the idea itself - user control getting acces to Master page variables?
View 2 Replies
Feb 8, 2010
I'm writing ASP.NET custom control, and I want it to have a few properties which should be visible only from code behind during run-time - I mean, these properties should not be visible both in a designer and in a aspx code of page containing this control. I've tried to use following attributes:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false)]
public List<Item> SomeData
{
...
}
but unfortunately this property is still visible in an Intellisense combobox when editing aspx page. Is it possible to hide this property everywhere besides server-side code ?
View 2 Replies
Aug 1, 2010
I have custom server control contains templatefield when an out button clicked the field disappear , when can I rebind the control (inside its class) supposed that Control.Page.OnInit+=new EventHandler(rebind()) doesn't do any things ?
View 4 Replies
Mar 25, 2011
i have a user control page and only have , which i have <div> and a gridview inside <div>how can i add a scroll bar in user control page?the code like below in aspx:<@regrister url="user control page" tagname="xx" tagprefix="aa"><div><aa: id="xx"></div> <--to embed user control page.
View 3 Replies
Jan 21, 2010
I am using BlogEngine.net and just created a theme (site.master) file and works but when I add a literal control and try to call a function from App_Code I get a 'Compiler Error Message: BC30002: Type 'basicFunctions' is not defined.' error. I call functions from basic_functions.vb in normal .aspx pages at the root. Since my error page is in a subfolder that has it's own App_Code folder, do I have to do something different?
/toolkit/themes/CommercialSilk/site.master
HTML Code:
[code].....
View 6 Replies
Aug 20, 2010
I am having problems with a user control. I want my solution to have a separate project for holding my user controls.The main project can get a reference to this user control project and can import this user control dll into my main project.
View 3 Replies
Feb 2, 2011
I'm a newbie here. I have created a custom control that requests a set of data from a user. However, I want to be able to have a variable number (dictated by the user) of these data sets entered on each page. How can I create and refer to a variable number of instances of a user control on a single page? It's hard to explain in words, but I'm basically looking for some way to do what amounts to the following:
[code].....
Is there a straightforward way of doing this? I haven't been able to find a clear answer via Google, which brought me to this group.
View 2 Replies
Mar 11, 2010
I have a set of links that exist in the master page. I have a css class i would like to assign to a particular one of them depending on if that is the page you are at during page load. ex: Home will have the current_page_item class if you are at the index page
This is what I have:
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DirectCast(Me.Master.FindControl("ctl00_homeLi"), HtmlGenericControl).Attributes.Add("class", "'current_page_item'")
End Sub
View 8 Replies
Nov 5, 2010
I have read about the file upload control in asp.net and tried it and works great. But I want to know if I can use it for another purpose. I have a video capture control that can be used for webcam apps or anything else. It has a method called HTTPUpload where it will upload an image file to the server using the HTTP upload protocol. My question is can i use the .net FileUpload control for this? And if so, how can I pass the image file straight to the .aspx page without having to submit a button? Would the file be as a query string variable?
Arguments:
WebServer = web server address
WebPage = name of upload web page
Fields = list of 'fieldname' and 'fieldvalue' values delimited with '|'
Files = list of 'fieldname' and 'file path' values delimited with '|'
Returns TRUE if successful, or FALSE otherwise.
Example
vcx.HTTPUpload "[URL] , "upload.asp",
"field1|value1|field2|value2" ,
"file1|c:foldermypic.jpg|file2|c:foldermyvideo.avi"
View 3 Replies
Oct 28, 2010
I am showing Custom Error in my page.if somehting happend wrong. but if the same error occured in my subview master page I am not able to show the Custom error page on Entire page its showing me that Error page under subview master page.I am attching the Screen shot.Can any body help me out how to show the Error page on entire page if something happend in any where submaster or other page.Here is the code that I am using in web config file to show custom Error page..
[CODE]...
Here I know the issue what's going on.This issue is occurring because i am using AJAX to partially load the contents of the tabs after the initial page load so the error is occurring AFTER my master page has been loaded.What I need to do is provide a javascript function to handle the error after the ajax call has returned and redirect to the error page.How to write this Javascript and where Do I need to write this?
View 4 Replies
Jan 2, 2010
there is a sample code for creating a custom textbox control with built in validation posted here Building ASP.NET TextBox with Integrated Validation And Switchable Input Modes. Inside the code there is a call to Controls.Add(validator) which adds the asp.net validator control to the textbox. when the textbox is used on the page, the validator is rendered to the page although the validator is added to the textbox and not to the page!
View 1 Replies
Mar 25, 2011
My intention is to give the user a flexible user control on a master page that does the following:
When navigating, a child page will pass the URL (with querystring) and PageTitle to the user control. The user control will take those two parameters and insert them as a "breadcrumb" object at first index of a List<breadcrumb> collection
This part works fine through the use of a Repeater with a LinkButton contained in an ItemTemplate. The user sees each of the pages he has been visiting in descending order, the provided benefit is a quick way to re-open records they have recently modified or created.
The part I'm having trouble handling is what happens when the user clicks the LinkButton, which is that the child page adds a new reference to the URL at the beginning of the List<> collection and I cannot seem to control the behavior of removing the LinkButton before it gets re-created. What I've tried doing is:
List<>.RemoveAt(RepeaterCommandEventArgs.Item.ItemIndex);
Repeater1.Controls.Clear();
Repeater1.DataSource = List<>;
Repeater1.DataBind();
While that should work, my CreateBreadCrumb(string url, string title) function gets called by the child page before the UserControl detects the Repeater1_ItemCommand event, so in effect it appears that the wrong ItemIndex is being used for removal.
View 1 Replies
Feb 12, 2010
I have a control that renders different children according to a property value. All works great until I add a rating control in the mix. I get the following:
Page cannot be null. ensure that this operation is being performed in the context of an ASP.NET request.
[Code]....
View 4 Replies
Mar 29, 2010
All i need is to generate a (x) number of slides on one page the number of slides will depend on the number of rows returned by a dataset.
View 2 Replies