AJAX :: Dynamically Generate/destroy LinkButtons And Their Animationextenders Out Of A Database?
Jul 7, 2010
I played around with the Ajax Control Toolkit Framework, and I wanted to know whether it is possible to implement this:
When loading a page, a database query executes that returns a list of titles. this is quite easy so far.According to the list-count and the separate title strings, LinkButtons are rendered vertically on the page. Is it possible to also dynamically create an AnimationExtender for each LinkButton?I'd like to fade out (and delete) every LinkButton as soon as the user clicks on it, and in the same time move the LinkButtons below the faded one up by x pixels.
I have a pretty simple C # page that when the page first loads, a bio is diplayed in that center section based upon sql executed from my code behind. I have 4 link buttons on the page that when clicked, fill that center section with other content based upon which link button they clicked (News, Publications, Contact Info, and Presentations). I was all done, then I thought about using an UpdatePanel to get rid of the annoying "flicker" when the page posts back on the click of the link button.
im showing 3 rows and 2 columns in a Gridview...I want to generate a 3rd column at runtime in a Gridview ....
only 1 LinkButton in Gridview at position row1 and column 3 only 2 LinkButton in Gridview at position row2 and column 3 only 3 LinkButton in Gridview at position row3 and column 3
I've been struggling with this for several hours now so I thought I'd give this forum a try. The problem is that I'm adding two kind of buttons (editBtn and delBtn) which show up fine but they won't fire their respective method when clicked. I also have a third button which works just fine.
I've got a repeater that's used to display the output of a dynamic report that takes criteria from webcontrols on the page. Within the repeater's ItemDataBound method I'm adding controls (Linkbuttons for sorting by column values) dynamically to the header of the repeater based on values selected in a checkbox list and at this point setting the CommandArgument and CommandName properties of the linkbuttons.
The issue is that when the linkbuttons are clicked they don't fire the ItemCommand event although they are clearly being correctly created and added to the header (there is some additional code to set the cssClass, text etc. and this works as expected.) The first column header in the repeater is set in the markup and the itemcommand event fires correctly on this one only. When the other column headers are clicked the repeater rebinds as programmed, but the columns are not dynamically re-generated.
Nightmare.ascx <asp:repeater runat="server" id="rptReport" OnItemDataBound="rptResults_ItemDataBound" OnItemCommand="rptResults_ItemCommand" EnableViewState="true"> <headertemplate> <table> <tr runat="Server" id="TRDynamicHeader"> <th> <!-- This one works --> <asp:Linkbutton runat="server" CommandName="sort" commandArgument='<%# Eval("Name")%?' /> </th> <!-- additional header cells get added dynamically here --> </tr> </headertemplate> <itemTemplate> <td><%# Eval("Name")</td> ... </itemTemplate> </asp:repeater> Nightmare.ascx.cs protected void PageLoad(object sender, eventArgs e){ if (! isPostback){ setupGui();//just binds dropdowns etc. to datasources } } protected void btnRunReport_Click(...){ List<ReportLines> lstRep = GetReportLines(); rptReport.DataSource = lstRep; repReport.DataBind(); } protected void rptReport_ItemDataBound (...){ if (e.Item.ItemType == ListItemType.Header) { foreach (ListItem li in chbxListBusFuncs.Items) { if (li.Selected) { th = new HtmlTableCell(); lb = new LinkButton(); lb.CssClass = "SortColHeader"; lb.CommandArgument = li.Text.Replace(" ", ""); lb.CommandName = "sort"; lb.Text = li.Text; th.Controls.Add(lb); ((HtmlTableRow)e.Item.FindControl("TRDynamicHeader")).Cells.Add(th); } } } if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //Row level customisations, totals calculations etc. } } <!-- this only gets called when the 'hardcoded' linkbutton in the markup is clicked. protected void rptReport_ItemCommand(object sender, Eventargs e){ lblDebug.Text = string.Format("Well? What's Happening? -> {0}:{1}", e.CommandName, e.CommandArgument.ToString()); } (The only thing that can call the runreport routine is a single button on the page, not shown in the code snippet above.)</textarea></p> <input type='hidden' name='ID[3]' value='82079' /> <input type='hidden' name='URL[3]' value='http://forums.asp.net/t/1472917.aspx' /> <input type='hidden' name='CAT[3]' value='Forms Data Controls' /> <input type='hidden' name='BOARD[3]' value='microsoft' /> <input type='hidden' name='P_DATE[3]' value='Sep 21, 2009 02:16 AM' /> <input type='hidden' name='RANDOM[3]' value='uck4OZUSh' /> <input type='hidden' name='REPLIES[3]' value='6' /> <input type='hidden' name='USER[3]' value='aziz' /> <p><input class=subject type='text' size='90' name='SUBJECT[3]' value='Forms Data Controls :: ValidationGroup causes button not to fire ItemCommand event' /><select name='INDEXED[3]'><option value='1' selected>UPDATE</option><option value='2'>DELETE</option></select>Sep 21, 2009 02:16 AM - Replies: 6 CAT: Forms Data Controls<a target=_blank href="http://forums.asp.net/t/1472917.aspx">View</a></p> <p> <textarea rows=10 cols=100 name='POST[3]' onfocus='setSelRange(this, 0, 0)'/>
I have a page with a couple of RequiredFieldValidators, each in its own ValidationGroup. One of the RequiredFieldValidator controls is inside a Datalist and the submit button triggers the relevant DataList_ItemCommand. It works just dandy until I add the ValidationGroup to the button, at which point clicking on the button no longer fires the DataList_ItemCommand event. Here is the HTML
[Code]....
Note that the ValidationGroup name is there, and it is unique. No other ValidationGroups exist with that name. As it stands, this code does NOT fire the DataList_ItemCommand event, so no update occurs. However if I remove the ValidationGroup declaration from the Button control, the event fires properly.
i have a repeater with a button in the footer template which i want to be able to update any of the items that are added (update quantites/totals/delete the item). however the 'UpdateOrderDetails' event never fires when the button is clicked. here is the code within the repeater...
<ItemTemplate> <tr> <td> <asp:CheckBox ID="chkDelete" runat="server" /> <asp:HiddenField ID="hidProduct_Key" runat="server" /> </td> <td><asp:Literal ID="ltlProduct_Name" runat="server" /></td> <td><asp:Literal ID="ltlProductOption_Size" runat="server" /></td> <td><asp:Literal ID="ltlProductOption_Code" runat="server" /></td> <td><asp:TextBox ID="txtQuantity" runat="server" /></td> <td><asp:Literal ID="ltlItemPrice" runat="server" /></td> <td><asp:Literal ID="ltlLineTotal" runat="server" /></td> </tr> </ItemTemplate> <FooterTemplate> <asp:Panel ID="pnlFooter" runat="server" Visible="False"> <tr id="trTotalExVAT" runat="server"> <td colspan="6">Total (ex VAT)</td> <td><asp:Literal ID="ltlTotalExVAT" runat="server" /></td> </tr> <tr id="trVAT" runat="server"> <td colspan="6">VAT</td> <td><asp:Literal ID="ltlVAT" runat="server" /></td> </tr> <tr> <td colspan="5"> <asp:Button ID="btnUpdate" OnClick="UpdateOrderDetails" Text="Update" runat="server" /> </td> <td>Delivery</td> <td><asp:Literal ID="ltlDelivery" runat="server" /></td> </tr> <tr> <td colspan="6">Total</td> <td><asp:Literal ID="ltlTotal" runat="server" /></td> </tr> </asp:Panel> </table> </FooterTemplate> the 'updateorderdetails' event in code behind is here Public Sub UpdateOrderDetails(ByVal s As Object, ByVal e As RepeaterCommandEventArgs) For Each objRepeaterItem As RepeaterItem In rptOrderDetails.Items Select Case objRepeaterItem.ItemType Case ListItemType.AlternatingItem, ListItemType.Item Dim chkDelete As CheckBox = objRepeaterItem.FindControl("chkDelete") Dim hidProduct_Key As HiddenField = objRepeaterItem.FindControl("hidProduct_Key") Dim txtQuantity As TextBox = objRepeaterItem.FindControl("txtQuantity") ' check for deletion or update If chkDelete.Checked Then Me.Basket.RemoveProduct(hidProduct_Key.Value) Else ' check for update If IsNumeric(txtQuantity.Text) AndAlso CInt(txtQuantity.Text) >= 0 Then Me.Basket.Products(hidProduct_Key.Value).Quantity = txtQuantity.Text End If End If End Select Next ' update order details BindOrderDetails() End Sub but this procedure is never called when the button is clicked, so wondered what i need to do to get this working </textarea></p> <input type='hidden' name='ID[5]' value='49574' /> <input type='hidden' name='URL[5]' value='http://forums.asp.net/t/1522852.aspx' /> <input type='hidden' name='CAT[5]' value='Web Forms' /> <input type='hidden' name='BOARD[5]' value='microsoft' /> <input type='hidden' name='P_DATE[5]' value='Feb 07, 2010 06:01 AM' /> <input type='hidden' name='RANDOM[5]' value='OoKSV9VFH' /> <input type='hidden' name='REPLIES[5]' value='3' /> <input type='hidden' name='USER[5]' value='aziz' /> <p><input class=subject type='text' size='90' name='SUBJECT[5]' value='Web Forms :: ItemCommand not get fire of datalist in IE' /><select name='INDEXED[5]'><option value='1' selected>UPDATE</option><option value='2'>DELETE</option></select>Feb 07, 2010 06:01 AM - Replies: 3 CAT: Web Forms<a target=_blank href="http://forums.asp.net/t/1522852.aspx">View</a></p> <p> <textarea rows=10 cols=100 name='POST[5]' onfocus='setSelRange(this, 0, 0)'/>
I have imagebutton inside datalist.....the problem is that onclick event of serverside not get executed for only IE ..but its work fine for mozzila....i m not getting what wrong in this code.
I am using the tab control and basically I have 4 buttons. Each button will load a seperate ascx control into a brand new tab. After about 4 tabs, since it has to regenerate all 4 tabs, the speed in order to add tabs just becomes too long for my tastes. Is there any way to remedy this and make it go faster?
EDIT2:Using Internet Explorer 7.0 and 8.0
EDIT: Some Code, I store the i in viewstate and loop through this every time for each panel per regeneration
private void BuildNewTab(int i) { TabPanel newPanel = new TabPanel();[cod]....
Ok, so I'm adding linkbuttons to a page dynamically on page_load.I had it to where the link buttons were redirecting to a page with a query string attached. I was attempting to use the AjaxToolKit's AjaxFileUploader and ran into issues with existing query strings.
So what I'm trying to do now is handle the click event of the linkbutton server side, set 2 session variables and then redirect the page to the same page, but with out appending a querystring so the ajaxfileuploader will work correctly.Here is my linkbutton code:
vb Code: Dim Lin As New LinkButton Lin.Text = dr("DeptDesc").ToString Lin.CssClass = "deptlink" Lin.ToolTip = CDate(dr("MeetingDate").ToString).ToFileTime.ToString 'Lin.OnClientClick
[code]....
I know I have Lin.PostBackURL and Lin.setAttribute(...). It didn't work with just setAttribute and I saw a post online about someone setting the PostBackURL and it working...
I am building a website using ASP.net ajax. there are 3 <asp:panel> controls in the page and each contains a number of dynamic linkbuttons. these panels are contained in a <asp:updatepanel> control the page_load event fills out the first panel with linkbuttons and assigns cooresponding commandName commandArgument for them, that works. then the first panel's linkbuttons triggers the command and fill out the second panel with linkbuttons, that works too. then the seond panel's linkbuttons are supposed to fill out the third panel with linkbuttons, but that doesn't work anymore, and it seems like doing the page_load event again and filling out the first panel and the second panel's linkbuttons disppear, just like the first time the page is loaded.
I have a control that I use to populate a cascading menu with LinkButtons. All link buttons have the same OnClick event that I want to use to load content as well as change the clicked button's color to show the user which LinkButton they have selected.
My problem is that I don't know how to access any LinkButtons other than the one that is calling the OnClick event, so any colored button remains that color when other boxes are selected.
Is there any way I can reference all LinkButtons within a Panel to clear their colors so only the selected LinkButton is colored?
In this repeater linkbuttons are generetaed with an onclick event.This onclick event sets a multiview to the corresponding view.The multiview is in an update panel as well.When a linkbutton in the repeater is clicked the corresponding view is shown, but a complete refresh of the page is done.How can this be prevented, because when I have just linkbuttons on the page (so not in a repeater) that set the multiview to the corresponding view, only the multiview is refreshed instead of the complete page
I have controls which are added at run-time to a PlaceHolder control on the page which is inside an UpdatePanel. The first refresh of the UpdatePanel is fine but subsequent actions create copies of everything on the page. I get two sets of the run-time added controls on the same page. It's not smart enough to realize that the second set replaces the first set. Has anyone else seen this? Runtime added linkbuttons into UpdatePanel ;fullpostbacks instead of asyncpostback.All parameters of UpdatePanel are default. adding controls runtime like this:
I have a site that gets deployed to over a dozen clients. The main website has a base template, and each client has a client folder that overrides the colours. The problem is that there are a lot of CSS files, so making a change that forces us to update every client takes a long time. The automated build process takes care of replacing the updated files.
I would like to change the CSS files to be usercontrols instead, and those usercontrols could then inherit from another usercontrol where client specific values are stored.
So instead of having a forms.css file and then a /client/forms.css file I would have a Forms.ascx file that inherits from a usercontrol that contains the colours.
Ex:
[code]....
Then the masterpage would inherit from the usercontrol instead. This would make the maintenance of the client sites much easier.
If this is possible, would it also be possible to have the Forms.ascx control output the markup as CSS? Or make the extension .css and still have the ascx properties?
I have about 10 different objects that get populated from user input. Instead of creating 10 different view pages, is there a way to dynamicaly generate the input form and have only one view page? What I am looking for is a run-time solution like the form generator in visual studio when you "Add View".
I have a sp that generates a result looks like below
Userid orgid
1 100 1 200 1 400 2 100
I would like to generate a string something like below by looping thru the output result data table using ado.netUserid 1 should generate It needs to generate below statement surround by {} and separated by comma(,) if it has multiple orgids.. and orgid( after & ) need to be dynamically assigned in the string based on the table..
How can I dynamically generate this statement? I can generate the stament if there is only one orgid for user but if you have multiple orgs .. not sure how Ic an concatenate multiple orgids by comma..
I was interested to know whether or not asp.net is allows us to dynamically generate HTML inline on the .aspx Source page (not the code-behind). For testing I created the following simple .aspx page...
In my asp.net code-behind I have the following:
protected List<string> myList = null; protected void Page_Load(object sender, EventArgs e) { if (myList == null)[code].... Notice that the Repeater control did in fact create the four list items. However, the contents (One String, Two String, etc) of the myList list did not come along for the ride.What do I need to do to evaluate the myList list and get its values inside the list item tags? By the way, I'm not concerned with how to use the Repeater control specifically, so if there is a solution to this problem that does not include the Repeater control, I'm fine with that.
Note: I'm aware that I can bind the "myList" generic list to an asp:BulletedList and get the same result. I am more interested in dynamically creating HTML inline of the Source page.
This has got to be more simple than I'm making it. I want to generate a listbox with years for the values. It needs to be dynamic. It needs to list from 17 years ago to 25 years ago. This is what I have so far, I get the correct number of items in the listbox, but I don't get the correct value. They are all "1985".
<% Dim y As Integer Dim NextTime As Date = Now Dim bday_yr As New ListItem() y = 0 For y = 17 To 25 NextTime = DateAdd(DateInterval.Year, -y, System.DateTime.Now) bday_yr.Value = NextTime.Year bday_yr.Text = NextTime.Year BirthYear.Items.Add(bday_yr) Next %> <asp:DropDownList ID="BirthYear" runat="server"> </asp:DropDownList>
I have a 3 layer aps.net application (DAL, BLL,PL)
I wanted to create a horizantal menu and then to populate/enable/disable the items of the menu depending on the user has permision of a specific form/page or not.
The backend/ data base work is complete. I give rights to a user/role on a specific page and I
also develope functions/procedures to check the user rights/retrieve all pages on which the user has rights.
The missing part is the front end, How I can implement this on the front end?
If I got some standard way, I will immplement it in all my future asp.net apps, As most of our apps have some menu and we want to display mentu items to the user depneding on the rights.
I may want to clear one thing here that I want a horizantal menu but there is no horizantal menu in aps.net tree view.
I have Dynamically generated HTML Table which has dynamically generated button in one of its column. If that button is clicked it adds a textbox to the very next row using javascript.I encountered a problem in identifying which column's button is being clicked.Please someone help me how to get the particular row index of a table of which button is being clicked. And how to send that rowindex to the javascript function which generates the textboxes.
I am trying to integrate URL.... I am selecting urls of 3 images from database and and displaying those 3 images from a particular album. Now the problem is that what if the user has multiple user? It should be able to generate as many Jquery albums on the page as there are in the database associated with that user.
I am trying to generate a Grid view from database, in one of my database columns the values are 'y' and 'N'. and i need to show this values in a check box .I tried to keep a check box in item template and tried to bind it, but could get much success.