.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Jean Paul
abhays
satyapriyanayak
SP
ASPEvil
Post New Web Links

Building Re-Usable ASP.NET User Control and Page Libraries with VS 2008

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
 

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. 


Thanks in advance,

Dheeraj Mittal

dhemittal@gmail.com




View Complete Post


More Related Resource Links

Help building a user control to track page visits

  

Greetings,

My intention is to give the user a flexible user control on a master page that does the following:

  1. When navigating, a child page will pass the URL (with querystring) and PageTitle to the user control
  2. 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_Ite

GDI+: A Primer on Building a Color Picker User Control with GDI+ in Visual Basic .NET or C#

  

Although most developers and APIs use the RGB scheme when working with colors, it's not the only available way to represent or select colors. For instance, the standard Windows color-selection dialog box allows you to work with the HSL color scheme in an indirect way. In this article, the author describes several color selection schemes, and uses GDI+ (via the System.Drawing namespace) to create a component that makes it possible for your own applications to provide a simpler, friendlier color chooser. Along the way, you'll get tips to help you use GDI+ in your own apps.

Ken Getz

MSDN Magazine July 2003


Knowing the event occured in user control in current page

  

Hello,

 

      My web application has user control which uses third party controls called Devexpress controls. The user control is a menu  and is part of the Master page. It is placed there because this needs to be available in all the pages. My user controls raises a even on item clicked. Now, My question is that Is there any way to know that the event has occurred in page_load of the current page in which I am in?



User Control not accessing the value of the properties send to it from the aspx page.

  

I have a dynamic accordion on a page. Set its datasource to an object of paged data source.The user control is in the accordions content template. When i was writing code the properties were showing but after giving the values of databases as

<ContentTemplate>

<uc:UserControl1  runat="server" Property1='<%#DataBinder.Eval(Container.DataItem,"columname1")%>' Property2='<%#DataBinder.Eval(Container.DataItem,"columname2")%>'  ></uc:UserControl1>

</ContentTemplate>

but the values shows null, these properties are shown as textboxes text property by user control.

MoreOver when I checked the values of database Items.So i made a textbox instead of usercontrol here as

<asp:TextBox ID="txtTest" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Columname1")%>'></asp:TextBox>

It is showing the correct value. And if i pass the value directly it is also showing correctly like

<uc:UserControl1  runat="server" Property1="XYZ")%>' Property2="ABC")%>'  ></uc:UserControl1>

. where I am wrong


the problem is eval is not passing the value to usercont

Building a user control with MVVM

  
Hi there, I created a custom user control that retrieve rows from database and will create all the buttons on runtime. My current approach is write all codes in the code behind of user control. And also I add a click event handler to each buttons that created on runtime. When any of the button is clicked, inside the click handler function will raise a RoutedEvent. And at the parent control, I add a handler to the custom user control to handle which button is clicked. The problems is : 1) I don't want to write all codes at the code behind. I tried to create a view model class for the user controls, but I failed to bind the event to view model as I wanted to retrieve the object that call this event. ICommand doesn't provide the information for it. 2) Even if I successful created a view model class, when a click event is triggered, the view model will handle it then it fire another event to user control class then the user control class fire another event to the main parent control. Which I think this is stupid >_< 3) I want to know how to user MVVM in this situation. Thanks & Regards, Rambo Ong

How to Access Parent Page (.aspx) control (IDs) from its child User Control (.ascx)

  
I have a parent .aspx page that has a asp:panel control in it, and this parent .aspx is also referencing a user control that I registered in that .aspx. Lets just call it usercontrolA.ascx for this post.The user control has a radiobuttonlist itself.Based on a selection from the radiotbuttonlist in the user control, I want to be able to hide the asp:panel in my .aspx (parent) but unfortunately I cant' get it to work:parentPanel.visible = true;  <<< I trried this in usercontrolA.ascx.csBut the user control doesn't know about the panel in the parent .aspxSo do I need to expose that somehow from the parent so that I can access it from the code behind of the child .ascx?  How?

Accessing User Control that is in a Master Page

  
I have looked everywhere for how to do this and all I come up with is threads describing how to expose public properties.  I have a USER CONTROL in my  Master page. It is a search box with a text box and a dropdown for search type (last name, account number, etc) and a search button.  When the user clicks the search button, I open a new page that displays the results.  How do I pass the values from the USER CONTROL search fields to the new page?  I would post code, but I have nothing to post yet since I don't know where to start. I have tried exposing the public property of the user control, but I don't know how to retrieve those values on the results page.  Anyone have any sample code on how this is done? Thank you in advance for your help!

Accessing a public property of a nested user control in a master page from a pages' user control

  
Hi  I've got a web site that has a master page and that master page (mpMaster that has a user control (ucControl1) which has a sub user control (ucControl2), this user control has a property which accepts a value. Now, I have a page that uses the master page and on this page I have another user control (ucPageControl), I need to  find a way of setting the value in ucControl2 from ucPageControl. Is this possible at all? Many thanks Ed

Is there a way in VB.Net to embed a custom user control to a web page based on Word or Excel

  
Hi Everyone.  I'm looking to create a web page that would be used on a local intranet that would use a custom control based on Word and Excel.  I've used code previously to embed it in a Windows application but wasn't sure if anyone knew of any examples out there on how to embed a custom control into a ASP.Net page.

Multiple instance of User Control on Page - Button Click Event

  
Hi, I have this Web User Control, with 3 controls:<asp:TextBox ID="txtSearch" runat="server" /> <asp:RequiredFieldValidator ID="rfvSearch" runat="server" ControlToValidate="txtSearch" Display="None" /> <asp:Button ID="btnSearch" runat="server" onclick="btnSearch_Click" /> In code behind: protected override void Render(HtmlTextWriter writer) { rfvSearch.ValidationGroup = this.ID + "_validation"; txtSearch.ValidationGroup = this.ID + "_validation"; btnSearch.ValidationGroup = this.ID + "_validation"; base.Render(writer); } protected void btnSearch_Click(object sender, EventArgs e) { Response.Redirect("ResultadoSearch.aspx?argumento=" + txtSearch.Text); } When I try to add two UserControl and I Click in btnSearch of second UserControl, txtSearch.txt returns value of first User control.How I can get the value of second txtSearch?

referencing a user control in a master page

  

Hi,


I have the following code which at the moment sits in a number of pages:

    private void ConfigureEmailSignup()
    {
        ContentPlaceHolder cphBaseContent1 =
            (ContentPlaceHolder)Master.Master.FindControl("Base_Content1");
        if (cphBaseContent1 != null)
        {
            Controls_Email_Signup emailSignUp =
                (Controls_Email_Signup)cphBaseContent1.FindControl("Email_Signup");
            if (emailSignUp != null)
            {
                emailSignUp.DisplayType = "store-list";
            }
            else
            {
                // event log
            }
        }
        else
        {
            // event log
        }
    }


It sits in the page because I reference the usercontrol type 'emailSignUp' and pass data to an exposed variable 'DisplayType'.  The control is located in the pages master page. Ideally what i'd like to do is put this in its own class or something, so I can just call it passing the configuration variable, but I'm unsure how this would work - any advice would be appreciated.


Thanks


John


Calling parent page method from user control

  

I looked up the  threads about  this. But I couldn't do it...

this is my method in aspx.page:

public  void MesajlariGetir()
    {
        DataSet ds = new DataSet();


        SqlConnection con = new SqlConnection();
        SqlCommand cmd = new SqlCommand("msjlarigetir", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Kime", Session["kullaniciadi"].ToString());
        con.ConnectionString = cnnstr;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(ds);
        con.Open();
 
        pds.DataSource = ds.Tables[0].AsDataView();
        pds.AllowPaging = true;
        pds.PageSize = 10;
        pds.CurrentPageIndex = CurrentPage;

        DataList1.DataS

Get the value of a User control in a Page

  

In my ASpx page i want to get the value of a server control which is in a User Control

Please Help


Get the value of user control in an ASPX Page

  

I have a lebel in a UserControl with the name lblAmount and a textboxt in an ASPX page. now i want to assign the value of lblAmount (Lebel in UserControl ) to the text box of the page


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend