I add linkbutton controls dynamically to a panel, this works fine, but I also add eventhandlers to them like this.. AddHandler mLink.Click, AddressOf mLink_OnClick But when I click the linkbutton links, the event never happend. I have one updatepanel wrapped around some panels. What could be wrong?
When the user selects an "account" we dynamically create a linkbutton with the selected dates. However, the linkbutton onclick handler doesn't fire when the button is clicked.
Dim linkBtn As New LinkButton linkBtn.Text = "blah" AddHandler linkBtn.Click, AddressOf linkButtonHandler linkBtn.ID = panelDatesRencontre.Controls.OfType(Of LinkButton).Count panelDatesRencontre.Controls.Add(linkBtn) ScriptManager1.RegisterAsyncPostBackControl(linkBtn) Dim Trigger1 As New AsyncPostBackTrigger Trigger1.ControlID = linkBtn.ID Trigger1.EventName = "Click" UpdatePanel2.Triggers.Add(Trigger1)
Answer: i make that in page_load, it seems to work
I have searched around but unable to find a solution that will work. I have a link button that is created dynamically during the page load. It is given an ID (obviously). There is a script manager on the page. I have the controls added to a panel in the updatepanel (updatePanel1). There is a dynamic label that is also created with each link button. I can get a response from the linkbutton click event during a postback on the second time clicking the linkbutton, but I am getting a complete postback instead of the asyncpostback for that control. During the creation of the dynamic linkbuttons, I am also creating a dynamic trigger for each button and adding it to the updatePanel1. The Click event is not firing the method without doing a complete page postback.
I am building a web site with visual web developer 2010
I have a class (autoButton) that adds a button to a panel (on Default.aspx) and a handler w/i the same class (classifyEventHandler)
The button appears fine, but when clicked the even doesnt fire, what am I doing wrong?
I tried locating the event handler in default.aspx, but it was not found :P
Imports Microsoft.VisualBasic Public Class autoButton Public Sub makeClassifyButton(ByVal theCell As Object) Dim myButton As New Button myButton.Text = "classify" myButton.ID = "b_classify_" + theCell.ID AddHandler myButton.Click, AddressOf classifyEventHandler theCell.Controls.Add(myButton) End Sub Private Sub classifyEventHandler(ByVal sender As Object, ByVal e As EventArgs) MsgBox("done?!") End Sub End Class
I have a gridview with a onrowdeleting="SellersGridView_RowsDeleting" switch. My method is:
[Code]....
Well, it seems that when I try to delete anything - nothing happens. I tried to change the first line to Response.Redirect("foo") just to check if the event itself is fired, and it turns out that it doesn't.
i have a JQuery ui dialog box that opens up as a contact form when a link is clicked, which works fine, my problem is trying to submit the information.
When you click the send button it fires a button click event of another asp:button ive got hidden on the page...
the post back event fires and the page reloads but the asp:button click event doesn't not fire?
I have a multi view with 2 view in my page. when page is loading first view is set active. by click on a click I set active second view that contain AsyncFileUpload1. but UploadedComplete event doesn't fire. This control works outside of view correctly but into view doesn't work. I have to use multi view and this 2 view in my web page. what can I do?
My repeater is available in a user control and I added the user control as a web part to an existing webpartzone. I could see all rows in the repeater (along with buttons). Once I click the (any) button, it loses all the rows and itemcommand never fires. I am using ASP.NET 4.0
MdsMenu:MenuItem is my custom WebControl. If I insert a Button control out of MdsMenu:MenuItem tag it works well but if I inserted it within MdsMenu:MenuItem tag it doesn't fire the concerned method. What's wrong with my code?
Edit: Menu.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Security.Permissions; using System.Collections; using System.ComponentModel.Design; using System.Drawing.Design; using System.Web.UI.HtmlControls; using System.IO; namespace MenuServerControl { [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [DefaultProperty("MenuItems")] [ParseChildren(true, "MenuItems")] [ToolboxData("<{0}:Menu runat="server"> </{0}:Menu>")] public class Menu : WebControl { #region Fields private List<MenuItem> _MenuItems; string _Direction { get { string direction = ""; switch (this.Direction) { case Directions.LeftToRight: direction = "direction:ltr;"; break; case Directions.RightToLeft: direction = "direction:rtl;"; break; default: direction = "direction:rtl;"; break; } return direction; } } string _AnimationDelay { get { if (AnimationDelay == null) AnimationDelay = 1000; return AnimationDelay.ToString().ToLower(); } } string _AnimationType { get { switch (this.AnimationType) { case AnimationType.Opacity_Height: return "animation:{opacity:'show',height:'show'}"; case AnimationType.Opacity_Width: return "animation:{opacity:'show',width:'show'}"; case AnimationType.Opacity: return "animation:{opacity:'show'}"; case AnimationType.Height: return "animation:{height:'show'}"; case AnimationType.Width: return "animation:{width:'show'}"; case AnimationType.Height_Toggle: return "animation: {height: 'toggle'}"; case AnimationType.Width_Toggle: return "animation: {width: 'toggle'}"; default: return "animation:{opacity:'show',height:'show'}"; } } } string _AnimationSpeed { get { switch (this.AnimationSpeed) { case AnimationSpeed.Fast: return "speed:'fast'"; case AnimationSpeed.Normal: return "speed:'normal'"; case AnimationSpeed.Slow: return "speed:'slow'"; default: return "speed:'fast'"; } } } string FloatStyle { get { if (Direction == Directions.RightToLeft) return "float:right;"; else return ""; } } string _Main_ul_CssClass = ""; #endregion #region Properties public string Main_ul_CssClass { get { if (string.IsNullOrEmpty(_Main_ul_CssClass)) return ""; _Main_ul_CssClass = "class=" + _Main_ul_CssClass; return _Main_ul_CssClass; } set { _Main_ul_CssClass = value.Trim(); } } public Directions Direction { get; set; } public int? AnimationDelay { get; set; } public AnimationType AnimationType { get; set; } public AnimationSpeed AnimationSpeed { get; set; } public bool DropShadow { get; set; } public bool AutoArrows { get; set; } [Category("Behavior")] [Description("The menu collection")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [PersistenceMode(PersistenceMode.InnerDefaultProperty)] public List<MenuItem> MenuItems { get { if (_MenuItems == null) _MenuItems = new List<MenuItem>(); return _MenuItems; } } public VerOrHor VerticalOrHorizontal { get; set; } #endregion #region Methods public Menu() { DropShadow = true; AutoArrows = true; } public override void RenderBeginTag(HtmlTextWriter writer) { writer.Write("<div id="" + this.ID + "" style="" + _Direction + " " + FloatStyle + "">"); } public override void RenderEndTag(HtmlTextWriter writer) { writer.Write("</div>"); } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); #region Adding Script & link Tags HtmlGenericControl jquery = new HtmlGenericControl("script"); jquery.Attributes.Add("type", "text/javascript"); jquery.Attributes.Add("src", Page.ClientScript.GetWebResourceUrl(typeof(MenuServerControl.Menu), "MenuServerControl.JavaScriptFiles.jquery_1_4_3.js")); jquery.EnableViewState = false; Page.Header.Controls.Add(jquery); HtmlGenericControl hoverIntent = new HtmlGenericControl("script"); hoverIntent.Attributes.Add("type", "text/javascript"); hoverIntent.Attributes.Add("src", Page.ClientScript.GetWebResourceUrl(typeof(Menu), "MenuServerControl.JavaScriptFiles.hoverIntent.js")); hoverIntent.EnableViewState = false; Page.Header.Controls.Add(hoverIntent); HtmlGenericControl jquery_bgiframe_min = new HtmlGenericControl("script"); jquery_bgiframe_min.Attributes.Add("type", "text/javascript"); jquery_bgiframe_min.Attributes.Add("src", Page.ClientScript.GetWebResourceUrl(typeof(Menu), "MenuServerControl.JavaScriptFiles.jquery_bgiframe_min.js")); jquery_bgiframe_min.EnableViewState = false; Page.Header.Controls.Add(jquery_bgiframe_min); HtmlGenericControl superfish = new HtmlGenericControl("script"); superfish.Attributes.Add("type", "text/javascript"); superfish.Attributes.Add("src", Page.ClientScript.GetWebResourceUrl(typeof(Menu), "MenuServerControl.JavaScriptFiles.superfish.js")); superfish.EnableViewState = false; Page.Header.Controls.Add(superfish); HtmlGenericControl supersubs = new HtmlGenericControl("script"); supersubs.Attributes.Add("type", "text/javascript"); supersubs.Attributes.Add("src", Page.ClientScript.GetWebResourceUrl(typeof(Menu), "MenuServerControl.JavaScriptFiles.supersubs.js")); supersubs.EnableViewState = false; Page.Header.Controls.Add(supersubs); if (Direction == Directions.LeftToRight) { HtmlGenericControl csslink = new HtmlGenericControl("link"); csslink.Attributes.Add("href", Page.ClientScript.GetWebResourceUrl (typeof(Menu), "MenuServerControl.CSS.superfish.css")); csslink.ID = "NavigationMenu"; csslink.Attributes.Add("type", "text/css"); csslink.Attributes.Add("rel", "stylesheet"); csslink.EnableViewState = false; Page.Header.Controls.Add(csslink); } else { HtmlGenericControl csslink = new HtmlGenericControl("link"); csslink.Attributes.Add("href", Page.ClientScript.GetWebResourceUrl (typeof(Menu), "MenuServerControl.CSS.RightToLeft superfish.css")); csslink.ID = "NavigationMenu"; csslink.Attributes.Add("type", "text/css"); csslink.Attributes.Add("rel", "stylesheet"); csslink.EnableViewState = false; Page.Header.Controls.Add(csslink); } if (this.VerticalOrHorizontal == VerOrHor.Vertical && this.Direction == Directions.RightToLeft) { HtmlGenericControl csslink01 = new HtmlGenericControl("link"); csslink01.Attributes.Add("href", Page.ClientScript.GetWebResourceUrl (typeof(Menu), "MenuServerControl.CSS.RightToLeft superfish-vertical.css")); csslink01.Attributes.Add("type", "text/css"); csslink01.Attributes.Add("rel", "stylesheet"); csslink01.EnableViewState = false; Page.Header.Controls.Add(csslink01); } else if (this.VerticalOrHorizontal == VerOrHor.Vertical) { HtmlGenericControl csslink01 = new HtmlGenericControl("link"); csslink01.Attributes.Add("href", Page.ClientScript.GetWebResourceUrl (typeof(Menu), "MenuServerControl.CSS.superfish-vertical.css")); csslink01.Attributes.Add("type", "text/css"); csslink01.Attributes.Add("rel", "stylesheet"); csslink01.EnableViewState = false; Page.Header.Controls.Add(csslink01); } #endregion } protected override void RenderContents(HtmlTextWriter output) { output.Write(CreateMenuHtmlTags()); } StringBuilder CreateMenuHtmlTags() { if (this._MenuItems == null) throw new Exception("تگ های مربوط به منو را کامل کنید"); StringBuilder Html = new StringBuilder(""); #region Add <Script> if (String.IsNullOrEmpty(Main_ul_CssClass)) Html.Append("<script>$(document).ready(function() { $("ul.sf-menu").superfish({pathLevels: 1,"); else Html.Append("<script>$(document).ready(function() { $("ul." + Main_ul_CssClass + "").superfish({ pathLevels: 1,"); Html.Append("delay:" + _AnimationDelay + ","); Html.Append(_AnimationType + ","); Html.Append(_AnimationSpeed + ","); Html.Append("dropShadows: " + DropShadow.ToString().ToLower() + ","); Html.Append(@"autoArrows: " + AutoArrows.ToString().ToLower() + "});});</script>"); #endregion if (string.IsNullOrEmpty(Main_ul_CssClass) && VerticalOrHorizontal == VerOrHor.Vertical) Html.Append("<ul class="sf-menu sf-vertical sf-js-enabled sf-shadow" id='sample-menu-1'>"); else if (String.IsNullOrEmpty(Main_ul_CssClass)) Html.Append("<ul class="sf-menu sf-js-enabled sf-shadow" id='sample-menu-1'>"); else Html.Append("<ul class="" + Main_ul_CssClass + "" id='sample-menu-1'>"); foreach (MenuItem item in _MenuItems) { if (item == null) continue; if (item.SubMenuItems != null && item.SubMenuItems.Count > 0) { Html.Append("<li" + item.li_CssClass + ">"); Html.Append("<a href="" + item.Href + "">" + item.Text.Trim() + "</a>"); ParseSubMenuItems(ref Html, item); Html.Append("</li>"); } else if (item.SubMenuItems != null) Html.Append("<li" + item.li_CssClass + "><a href="" + item.Href + "">" + item.Text.Trim() + "</a></li>"); } Html.Append("</ul>"); return Html; } void ParseSubMenuItems(ref StringBuilder Html, MenuItem menuItems) { if (menuItems == null) return; Html.Append("<ul " + menuItems.ul_CssClass + " style="display: none; visibility: hidden;">"); foreach (var item in menuItems.SubMenuItems) { if (item == null) continue; MenuItem Sub_MenuItem = item as MenuItem; WebControl webControl = item as WebControl; if (Sub_MenuItem != null) { if (Sub_MenuItem.SubMenuItems != null && Sub_MenuItem.SubMenuItems.Count > 0) { Html.Append("<li" + Sub_MenuItem.li_CssClass + ">"); Html.Append("<a href="" + Sub_MenuItem.Href + "">" + Sub_MenuItem.Text.Trim() + "</a>"); ParseSubMenuItems(ref Html, Sub_MenuItem); Html.Append("</li>"); } else if (Sub_MenuItem.SubMenuItems != null) Html.Append("<li" + Sub_MenuItem.li_CssClass + "><a href="" + Sub_MenuItem.Href + "">" + Sub_MenuItem.Text.Trim() + "</a></li>"); } else if (webControl != null) { Html.Append("<li>"); webControl.EnableViewState = true; this.Controls.Add(webControl); webControl.EnableViewState = true; StringBuilder sb = new StringBuilder(); sb.Append("<div>"); using (StringWriter sw = new StringWriter(sb)) { using (HtmlTextWriter textWriter = new HtmlTextWriter(sw)) { webControl.RenderControl(textWriter); } } sb.Append("</div>"); Html.Append(sb.ToString()); Html.Append("</li>"); } } Html.Append("</ul>"); } #endregion } } MenuItem.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; namespace MenuServerControl { [DefaultProperty("SubMenuItems")] [ParseChildren(true, "SubMenuItems")] [TypeConverter(typeof(ExpandableObjectConverter))] public class MenuItem : INamingContainer { #region Fields ArrayList _SubMenuItems; string text = ""; string href = "#"; string _ul_CssClass = ""; string _li_CssClass = ""; #endregion #region Properties [Description("متن منو آیتم")] [DefaultValue("")] [NotifyParentProperty(true)] public string Text { get { return text; } set { text = value; } } [DefaultValue("#")] [Description("<a /> href attribute")] [NotifyParentProperty(true)] public string Href { get { return href; } set { href = value; } } [DefaultValue("")] [Description("<ul /> css class")] [NotifyParentProperty(true)] public string ul_CssClass { get { if (string.IsNullOrEmpty(_ul_CssClass)) return ""; _ul_CssClass = " class="" + _ul_CssClass + """; return _ul_CssClass; } set { this._ul_CssClass = value.Trim(); } } [DefaultValue("")] [Description("<li /> css class")] [NotifyParentProperty(true)] public string li_CssClass { get { if (string.IsNullOrEmpty(_li_CssClass)) return ""; _li_CssClass = " class="" + _li_CssClass + """; return _li_CssClass; } set { this._li_CssClass = value.Trim(); } } [Category("Behavior")] [Description("The MenuItems collection")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [PersistenceMode(PersistenceMode.InnerDefaultProperty)] public ArrayList SubMenuItems { get { if (_SubMenuItems == null) _SubMenuItems = new ArrayList(); return _SubMenuItems; } } #endregion } }
I have my ReorderList setup, and it seems to work. It doesn't give me any errors, and it allows drag/drop of the entries.
BUT, it never updates my datasource. I have tried putting breakpoints on the update events, both on the reorder list, but also on the datasource, none fires.
I am building a website whereby people, before checking out of the shopping cart (and transferring to the payment iframe) can select which items from the shopping cart list to delete. The results from the shopping card are listed in a Repeater control. There is a Button in the Repeater which deletes a record from the database (used LINQ to SQL to do that.)
THe problem is that the ItemCommand event doesn't fire when i click the button. I tried 'response.write(test)' and it still would not work. It is as if the repeater cannot interact with the commands. It does render the results tho.
I am building a website whereby people, before checking out of the shopping cart (and transferring to the payment iframe) can select which items from the shopping cart list to delete. The results from the shopping card are listed in a Repeater control. There is a Button in the Repeater which deletes a record from the database (used LINQ to SQL to do that.)
The problem is that the ItemCommand event doesn't fire when i click the button. I tried response.write(test) and it still would not work.
It is as if the repeater cannot interact with the commands. It does render the results though.
I have a small website where I want to display a confirmation dialog after clicking on a button.
When you click the confirmButton the dialog appears. Then you can choose between Yes or No to either continue with the PostBack or to return.
Problem: The first time you get into the site all works fine. But after you click Yes to continue with the PostBack, no click event will be triggered anymore.
I create a dropDownList in code-behind, in selectIndexChange of another dropDownList, and add this new dropDownList to page using a placerHolder, everthing its ok, but new dropdownlist selectIndexChange event dont fire!
A little confused on something. I have a User Control in a master page. In the User Control there are image buttons. when I try to wire any click event even to say update a label in the User Control itself, nothing gets updated.
It is as if the postback is not handled at all.
What I want to do is click the image button in the User Control and then change a value in the master page. This could happen a few ways but for example it could update a public property or a control itself like a textbox or label.
Here is my situation: I have a overview of subscriptions that look simple:
Active (bool), ID (int), StartDate (datetime) and MaxUsers (int).
I've put this in a Gridview and it renders nicely.
Now everything is simply in ItemTemplates and are formatted.
Now a new feature: In the Gridview active should be a checkbox and when clicked on it, it should (de)activate the subscription. Or simply said, Active status is updated. Now me being a simpleton thinks:
[Code]....
and the cs:
[Code]....
But! the event doesnt get fired. Now I've searched with google and also through this forum and every time I get the answer: autopostback on true or use commandname. Now for this little feature I think the commandname use in combi with rowbound is overkill for such a little thing.
Now I hope I'm just missing something because this would be really nasty and stupid to make it so complicated. I like the autopostback and oncheckchanged combination because it logical, but why doesnt it work?
I have a modalpopup that i have opening on a radiobutton selection. That works great, opens when it should and closes when you click cancel. BUT i have the following on my cancel button event that is not firing
[Code]....
I also have a button event for my "OK" button and that works great, but my cancel event doesnt seem to fire or work. Maybe the ClearSelection() is not what i need..
I want to clear the radiobutton if they cancel out of the ModalPopUp so they can make a new selection, since its a required field.
I am adding some dynamic image buttons to a form in my code behind (vb.net) and added a click event handler, but it never fires. Also when I click on a button the page posts back and everything below my update panel disappears.
I've run into a problem with one of my web sites and I am having trouble figuring out the problem and a good solution. This is my scenario: I have a user control that displays a slideshow with images and some text that changes every fifteen seconds. To do this, I have an update panel that contains a timer control with an interval of 15000. It calls a method called slideshowTimer_Tick in the codebehind. The web page that contains this user control is a relatively simple page; no update panels or timers, just divs.
The problem I have is that if I have two of these user controls on the page, the tick event only fires for the first control. It never fires for the second control, although the control is full initialized otherwise.
I'm trying to manually create a button and add a Click event handler for it in code. However when the button is clicked the event handler doesn't seem to react on event (or event isn't called).
we tested the code in Visual Studio 2008 and everything worked just as it should. And I'm using Visual Web Developer 2005 XE. So I assume that I'm missing something to be done manually being in VWD 2005 XE, or the problem is in VWD 2005 XE it self.