create Link buttons Dynamically inside the Calendar and Fire Click Event

Hi ,

     In my application i need to develop calendar control containing link buttons clicking on the link it should redirect to other page. please see the below code

dateDisplayed method is calling  from OnDayRender Method

protected void DateDisplayed(object source , DayRenderEventArgs e)

{

......................

foreach (DataRow dRow in ds.Tables["WorkGroup"].Rows)

{

DateTime compareDate = Convert.ToDateTime(dRow["Act_StarDateTime"]);

compareDate =

Convert.ToDateTime(compareDate.ToShortDateString());

if (DateTime.Compare(compareDate, Convert.ToDateTime(e.Day.Date.ToShortDateString()))== 0)

{

int i = 100;

// Event matches date criteria ?display it...

LinkButton dailyEventLabel = new LinkButton();

dailyEventLabel.Text =

"<br />" + dRow["Act_Title"] ;

dailyEventLabel.ID =

String.Concat("btnAddCart-", i);

dailyEventLabel.CommandArgument = i.ToString();

dailyEventLabel.Click +=

new EventHandler(this.ButtonHandler);

i++;

e.Cell.Controls.Add(dailyEventLabel);

}

}

}

private void ButtonHandler(object sender, EventArgs e)

{

Button btnAddCart = sender as Button;

Response.Write(btnAddCart.CommandArgument);

}

 

please suggest me what the wrong with this code its too urgent

 

 

0
prakashaii
1/24/2007 6:46:02 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
1478 Views

Similar Articles

[PageSpeed] 45
Get it on Google Play
Get it on Apple App Store

Hi,
try this solution:

 protected void Page_Load(object sender, EventArgs e)
 {
 handler();
 }
 private void handler()
 {
 if (Request["__EVENTTARGET"] != null && Request["__EVENTTARGET"] != "")
 {
 Response.Write(Request["__EVENTTARGET"]);
 DateTime dt = DateTime.Parse(Request["__EVENTTARGET"]);

// add your own logic here
 }
 }
 protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
 {
 LinkButton lb = new LinkButton();
 lb.Text = "sdfjsldfkjsklf";
 lb.ID = e.Day.Date.ToString("yyyy-MM-dd");
 lb.Command += new CommandEventHandler(lb_Command);
 lb.Attributes.Add("href", "javascript:__doPostBack('" + lb.ClientID + "','');");
 e.Cell.Controls.Add(lb);
 }

That caused by not generating a correct clientid, and proper href attribute.
The idea is to fill those attributes manually, and check in handler method on postback if the postback by a particular control.
Hope it helps.
 

0
Raymond
1/26/2007 7:43:02 AM

Hi ,

    Thanks for ur response it works me nicely

0
prakashaii
1/29/2007 1:18:20 PM
Reply:

Similar Artilces:

Dynamically created link button click event won't fire
You enter a number in a textbox, click Search, and stores results of a stored procedure in a DataTable. If there's more than one row in the table, it creates a LinkButton using the following code during the SearchButton_Click event to let the user choose which record they want to select: if (memberTable.Rows.Count > 1) //multiple individuals found for member number; display all to choose. {for (int i = 0; i < memberTable.Rows.Count; i++) { string memberNumberString = memberTable.Rows[i].ItemArray[0].ToString(); //other columns here for nameString, etc LinkButton nameLink = n...

How to create and handle click event of dynamically created Link Buttons??
Hello Can anyone tell me how to create and handle events of dynemicallly created Link buttons?? Thanx for help..   Hi,take a look at this article: Adding a dynamic control to a placeholder control and wire up the event.Grz, Kris. Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons.  I think u have created button in page load event    like Button btn = new Button();        btn.ID = "btnId";        btn.Text = "Submit...

Dynamically generated Button inside dynamically generated GridView inside ListView not firing Event
I've done tons of searching on this one to no real avail, so I'm posting here.  As a note, I've found multiple pages discussing this problem, but all of those solutions utilized a placeholder control, which I don't have the luxury of using.Here's a basic overview of what I have:A ListView ControlEmbedded into the ListViewItem is a GridView, utilizing a dynamically generated DataTable (due to a variable number of columns)A LinkButton in the footer of each GridView cell, which should fire an event to populate and show a Modal Dialog.The problem is that I can never get ...

Problem with dynamically created Link Buttons click events handlers.
Hi Friends, Here I am creating LinkButtons dynamically on an aspx form. And when I click on one of those Linkbuttons another set of LinkButtons1 appear. When I click on LinkButton1 I need to create another set of Link buttons2 on the same form in which all the three sets of LinkButtons should be visible to the user. On Page Load I am generating the first set of LinkButtons. When I click on them the LinkButtons1 set is been created. Till here it works 100%. But when I click on LinkButtons1 it dosent generate LinkButtons2 on the form. Could anyone please help me with this? here is my...

Wizard control and dynamically created link buttons' events not firing
Hello everyone,Like my subject line says, I'm having trouble accessing my link buttons' Sub after they are created.My page is fairly simple and here is the scenario:I have an array with 5 values set to either True or FalseIf the value is True in the array, I create a linkbuttonAfter the link button is created, I put it inside a Place Holder When clicked the link button should redirect the user back to the Wizard's index 0 This is the code that's inside the Wizard's Pre_Render event:  For j As Integer = 0 To aryTasks.Length - 1If aryTasks(j) = "True" Then lnkButton = New Li...

Button Event Inside User Control Not Firing when Dynamically Created and added to Page.
Hello, I am dynamically Loading multiple instances of a UserControl and adding them to the Page.Controls collection. When I run the page the dynamically created Usercontrols are displayed with the proper data. However, when I click a LinkButton I have included in the UserControl to hide certain elements within the User Control the Page Posts back but the LinkButton.Click event does not fire inside the User Control. Further, if I just hard code the user control into the aspx file (giving me just the one instance) and I click the LinkButton the Click event does fire ins...

Firing a Button Click event via the Enter Key on dynamically created TextBoxes
Hi all,   I have a form that has x number of  dynamically created Textboxes based upon which user is running the application, so I could have 3 or 10 textboxes on the screen.  The id's of the textboxes are "TB0" , "TB1"...... etc etc.   Also on the screen is a Button which submits background  SQL queries and produces a report (The Textboxes are report parameters).   The user would also like the ability to just hit the Enter Key as well as clicking on the Submit Button to start the query.    My question is:  how can I tie hitting t...

when the user clicks the image button to show the calendar extender on my web form it submits the whole form instead of showing the calendar??
when the user clicks the image button to show the calendar extender on my web form it submits the whole form instead of just showing the calendar??  I have another button that submits the form. my calendar image button is acting like a submit button also instead of acting like a calendar popout button. Does anybody know how I can set an image button to not submit the form and cause my validations to render. I only want it to pop out the Ajax calendar for the specific textbox?   <ajaxToolkit:CalendarExtender runat="server" TargetControlID="txt...

Please guide
Hi, I am creating dynamic panels and each of these panels have an image and a button. I would like to show a modal popup when the button of the panel is clicked. Contents of popup depend on which button was clicked. I would sincerely appreciate if some one could guide me if this is possible with Ajax and AjaxControltoolkit. Till now I tried to create modalpopupextended dynamically in the click event of button and page fails with an error message that TargetControl could not be found. Please guide. Regards & thanks Kapil    Hi Kapil, Unfortunately, the ModalPopup must h...

Link Button Event not Getting Fired when the button is clicked
Hi In the Inline code , i have any tables within a form. when i try to click the link button, the button event is not getting fired. Can any on slove this for me. Thanking you Solomon Hello, we would really want to help you, but we need to know more information, can u post some code please. regards.Bilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP i think the handles part is not there for the for that event. Search for handles linkbutton1.click in codebehind. if not found add it....

Web Parts & GridView button, link image click events does not fire on IE 7.0
 Hi,I have created a sample web app for testing in .NET Framework 3.5, used web parts added grid view into web part on the page to display the data. the button & link click events on these controls does not fire on IE 7.0 such as edit, select, delete,  buttons, paging & sorting in GridView and web parts restore button click events.I have executed the same application on Fire Fox browser, which is working fine.Please help me in fixing the problem how to run the same on IE 7.0 Shyam Sundar Hi shyam_eg, It should work . I strongly suspect you have disabled javascript...

Retrieve values from an array on click of a dynamic link button which is created in Gridview's RowCreated event (Clientside)
Modification in my previous question.I have created a dynamic link lbutton list of A-Z alphabets which are displayed in a grid on a row created event.I have a 2 dimensional array which is filled with firm names.I am filling this array on generating a report which is generated based on an object value supplied(from a CRM based API).Now,I have the values inside this 2 dim-array.1)I need to display the data into a control(any control which looks like a datalist or datalist as i want the horizontal Gridlines displayed in it) based on click of a particular alphabet link button i.e.,If i click on ...

An OnClick event doesn't fire up when a button is clicked in a Tab Panel in a Tab Container in an AJAX Web Form
Hello Post: I would like to enclose the following code so you can analize what is going on: "> " style="vertical-align:top;"> "> "> ...

how to create button controls dynamically .. then i need that click event of buttons
how to create button controls  dynamically .. then i need that click event of buttons  urgent ???????Vino  Add dynamic controls with eventsWebsite Design Darlington - http://mdssolutions.co.ukhttp://lessthandot.com - Experts, Information, Ideas & Knowledgehttp://aspnetlibrary.com - An online resource for professional ASP.NET developersPlease remember to click "Mark as Answer" on this post if it helped you refer below snippet..public partial class _Default : System.Web.UI.Page {    protected void Page_Load(object sender, EventArgs e)  ...

Web resources about - create Link buttons Dynamically inside the Calendar and Fire Click Event - asp.net.web-forms

iPhone 5 A6 chip to dynamically up-clock up to 1.3GHz (and downclock too)?
Interesting video from our friends at TLDToday: If this is not just a Geekbench app glitch, it could indicate why that A6 processor is so 2X ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

iPhone 5 Lightning port dynamically reassigns pins
... of Apple's Lightning USB cable shows that the pins on the plug aren't arranged symmetrically, suggesting that the Lightning port can dynamically ...

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...


A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 1/22/2016 7:20:02 PM