Single Calendar Control, Multiple displaying controls

Hello there,

     Technologies used : C# 2005, ASP.Net 2005

     Okay, this is the scenario, I am having some 5 textboxes, and 5 image buttons of calendar image, I dont want to create a calendar control for each time I press a different image button. I want to make use of the same calendar control to be used by all the available 5 image buttons. Like, if image 4 is clicked the same calendar opens up and after selecting date, it displays it in the corresponding TextBox4 control, like this, this must be achieved by all the available controls. How can I achieve this.

Thanks,

warm regards,

Shariff.

0
shariff
4/24/2008 11:29:49 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
822 Views

Similar Articles

[PageSpeed] 40

Here is a simple implementation you can expand on. I am not using ajax ,since you do not mention it.

 Calendar.aspx:

    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1"
            runat="server" Text="Button" onclick="Button1_Click" />
            <br />
            <br />
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <asp:Button ID="Button2"
            runat="server" Text="Button" onclick="Button2_Click" />
        <br />
        <asp:Panel ID="panel1" runat="server" Visible="false">
            <asp:Calendar ID="Calendar1" runat="server"
                onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>
        </asp:Panel>
    </div>
    </form>

calendar.aspx.cs:

    protected void Button1_Click(object sender, EventArgs e)
    {
        ViewState["theTarget"] = Button1.ID;
        panel1.Visible = true;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        ViewState["theTarget"] = Button2.ID;
        panel1.Visible = true;
    }

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        switch (ViewState["theTarget"].ToString())
        {
            case "Button1":
                TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
                break;
            case "Button2":
                TextBox2.Text = Calendar1.SelectedDate.ToShortDateString();
                break;
        }

        panel1.Visible = false;
    }

 

Please mark as answered if you receive the answer you were looking for,

0
adyle
4/24/2008 12:22:58 PM

Thanks, i totally forgot about switch, this example explains clearly how to implement in my scenario. Thanks a lot!!. appreciate it!!. cheers!!Cool

0
shariff
4/25/2008 8:59:46 PM
Reply:

Similar Artilces:

Single page with multiple user web controls VS Multiple page with specific user web controls
I have a question regarding single page with multiple user web controls vs multiple page with specific user web controls   Option 1: I am of the opinion to have multiple pages with specific user web controls and use an object to store all the information as the user navigates through the application. And finally at the end, read this object and save all the information to the backend database.   Option 2: My respected team member suggests that we have only one page, with all the specific user web controls and not use an object, instead show/hide the user web controls based ...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

multiple user control into a web form (how do I keep the status of each control?)
A user control implements a quiz.The control has a property (id_question) to choose the different question the user control have to display. The user control have another property, its STATUS (status = 1 mean to show the question, status=2 means to show a message to the user that have answered the question). In the user control there is a button, clicking the button to answer the question cause the control post the form and call a DB and register the answer. During Postback, in page_load method of the user control I change the status from 1 to 2 (from show quest...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

AutoComplete control display problem when used in a user control; and this usercontrol is appearing multiple time on form
Hi, I am using AutoComplete AjaxControlToolKit extender 1.0.20229.15278 on .NET 2.0 framework. I have a address user control which is used multiple places in single ASPX page. The  Problem I see is the first control shows the Autocomplte popup but another control does not show Autocomplete popup.  I have couple of guess - The BehaviorID is identical on control causing the trouble  - extender control not registered properly for second instance  Here is "the" code I am using for autocomplte extender  <ajaxTool...

controlling an object in a web control from the page the web control is placed in
I have created a web control in vb.net that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

Share single Popup Control from Multiple ModalPopupExtender with Multiple Target Control
Hi, recently I had a situation where I need to popup the same Modal Popup Panel from two different buttons(Target Controls). So I hooked two different modalpopupextenders to the two buttons with same popup control. It dosen't work. Is it a bug or its not working by design? Any suggestion? Like this modification to ControlToolkit's ModalPopup Sample         <asp:LinkButton ID="LinkButton1" runat="server" Text="Click here to change the paragraph style" />        <asp:LinkButto...

calendar control appears under all other web controls
I have a calendar control I created. It always shows up under all the other textboxes and dropdown menus on my form. How do I fix it so it is on top of everything? Heres my code <asp:textbox runat="Server" id="textbox1" cssclass="fieldlarge" width="150"/> <INPUT type="button" value="..." onclick="OnClick()"><br> <div id="divCalendar" style="DISPLAY: none; POSITION: absolute"> <table cellpadding="1" cellspacing="0"> <tr> ...

Multiple items in a single day within a Calendar Control .NET 2.0
Hello all   I have a calendar control that is attached to a database. It reads the database and places the dates into an array along with an event name. This all works fine until I want to add a second event on the same day. I also have a page for add new events the calendar. What I get is that I loose the first event description displayed in the calendar day and the new one is added. How do add multiple "events" to a calendar control? Any help would be appreciated. ICSTech  ...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Calendar control in web user control (ascx)
I have a web page called calendar.aspx It has calendar control and onselectionchanged i have a procedure (Change_Date). Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As System.EventArgs) If Not Request.QueryString("textbox") Is Nothing Then Dim strScript As String = "<script>window.opener.document.forms(0)." + Request.QueryString("textbox").ToString + ".value = '" strScript += CalPopup.SelectedDate.ToString("MM/dd/yyyy") strScript += "';self.close()" strScript += "</" + "script>" RegisterClientScriptBlock("Calendar_ChangeDate", strScript) End If ...

Making the .NET calendar control as a floating control
Hi, I need to implement the .NET calendar control as a floating control. Is it possible to do that? If so, can you let me know how to do that?With Regards,Saravana Kumar M R  You could use the calendar extender control in the AJAX control toolkit. You can download the toolkit here, and there is a sample here.My Blog...

Web resources about - Single Calendar Control, Multiple displaying controls - asp.net.web-forms

List of mammals displaying homosexual behavior - Wikipedia, the free encyclopedia
For these mammals, there is documented evidence of homosexual behavior of one or more of the following kinds: sexual behavior , courtship , affection ...

Facebook Displaying Page Insights On Page Admins’ Personal Pages?
Some Facebook page administrators are seeing modules on their personal pages displaying page insights ad, campaign , and like totals for pages ...

Facebook Displaying Unread Messages from Pages in a New Updates Module
Facebook is displaying a new “Updates” sidebar module which shows some users unread messages sent to them by Pages. Users will see the Updates ...

Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air CNN Live - YouTube
Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air Lemon held up a Confederate flag first before holding up the sign. He asked, ...

Hazelwood coal mine fire: Morwell residents displaying symptoms similar to cigarette smokers, expert ...
An expert says some locals near Victoria's Hazelwood mine fire have symptoms similar to cigarette smokers.

Police accused of displaying fake G20 weapons
Toronto's top police officer misled the public by displaying fake weapons used in a medieval-themed role-playing game to help justify their actions ...

No charges for U.S. host for displaying high-capacity magazine on TV
NBC television journalist David Gregory won't face charges for displaying a high-capacity ammunition magazine on his "Meet the Press" news program ...

Jays' Escobar suspended three games for displaying slur
Toronto Blue Jays shortstop Yunel Escobar has been suspended three games for displaying a homophobic slur on his eye-black during a game on Saturday. ...

Google Play Store now displaying age-based ratings
We reported back in May that Google was adding age-based ratings to all apps in the Play Store as determined by the International Age Rating ...

Apple displaying Ferraris & other cars at WWDC hinting at CarPlay announcements
... 2014 Filed under: AAPL Company , iOS Continue reading more about AAPL Company and iOS at 9to5Mac . What do you think? Discuss "Apple displaying ...

Resources last updated: 11/27/2015 1:20:20 AM