Search Results

Search found 171 results on 7 pages for 'autopostback'.

Page 1/7 | 1 2 3 4 5 6 7  | Next Page >

  • jQuery Autocomplete losing text on AutoPostBack

    - by Moose
    I have a jQuery Autocomplete field on an ASP.Net Webform and everything has been working great until now. I also have a DropDownList that I have a need to fire onSelectedIndexChanged with AutoPostBack. When I changed my code to do the AutoPostBack, the text field that has the jQuery AutoComplete on it comes back blank. However, if I look at the source of the page, the text is in the text field. If I now post the form, the page will send back a blank field. My Google-Fu is weak on this one, as I could not come up with any workaround for it. Has anyone had any issues like this with the Autocomplete field getting blanked out on an AutoPostBack, and how did you get around it? I can post code if it's really necessary, but I'd need to sanitize a lot of it before I could due to company policy.

    Read the article

  • Autopostback select lists in ASP.NET MVC using jQuery

    - by rajbk
    This tiny snippet of code show you how to have your select lists autopostback its containing form when the selected value changes. When the DOM is fully loaded, we get all select nodes that have an attribute of “data-autopostback” with a value of “true”. We wire up the “change” JavaScript event to all these select nodes. This event is fired as soon as the user changes their selection with the mouse.  When the event is fired, we find the closest form tag for the select node that raised the event and submit the form. $(document).ready(function () { $("select:[data-autopostback=true]").change(function () { $(this).closest("form").submit(); }); }); A select tag with autopostback enabled will look like this <select id="selCategory" name="Category" data-autopostback="true"> <option value='1'>Electronics</option> <option value='2'>Books</option> </select> The reason I am using “data-" suffix in the attribute is to be HTML5 Compliant. A custom data attribute is an attribute in no namespace whose name starts with the string "data-", has at least one character after the hyphen, is XML-compatible, and contains no characters in the range U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z). The snippet can be used with any HTML page.

    Read the article

  • ASP.net Modal Pop up extender and DropDownlist autopostback

    - by Jack
    Hi all. I have a gridview control where if the user click on the auto generated edit button. A window will pop up using modalpopup extender with a drop down list for user to select. The problem is the selectedindexchange event will not fire if autopostback is set to false but if i set the autopostback to true. the pop up will go away without going to the selectedindexchange event. is it possible to have a control with autopostback set to true inside the modal pop up?

    Read the article

  • Asp.net RenderControl method not rendering autopostback for dropdownlist

    - by Tanya
    Hi all, i am bit confused as to why asp.net does not render a dropdownlist with the autopostback property set to true when using the RenderControl method. eg Dim sw As New IO.StringWriter Dim tw As New HtmlTextWriter(sw) Dim table As New Table table.Rows.Add(New TableRow) Dim tr As TableRow = table.Rows(0) tr.Cells.Add(New TableCell) Dim tc As TableCell = tr.Cells(0) Dim ddlMyValues As New DropDownList ddlMyValues.ID = "ddl1" ddlMyValues.Items.Add("Test1") ddlMyValues.Items.Add("Test2") ddlMyValues.Items.Add("Test3") ddlMyValues.AutoPostBack = True tc.Controls.Add(ddlMyValues) table.RenderControl(tw) Debug.WriteLine(sw.ToString) my output renders the dropdown list without the onchange="javascript:setTimeout('__doPostBack(\ddl1\',\'\')', 0)" that is generated by asp.net when using the dropdownlist normally. Is there a work around to this?

    Read the article

  • TextBox doesn't fire TextChanged Event on IE 8, AutoPostback is true

    - by MaikoID
    Hi guys, I have the same thing, there are many TextBoxes with the event TextChanged set and with AutoPostback = true, and works in all browsers (Chrome, Opera, Firefox 3.6) except in IE 8, IE 6/7 I didn't test. I don't want to put the onblur event in all my TextBoxs because there are many pages with many TextBox that use this event. Description I'm using a masterPage, in the aspx i have <asp:TextBox ID="txtCnpj" runat="server" CssClass="txt" Width="200px" onkeyup="Mascara(this,Cnpj)" onkeydown="Mascara(this,Cnpj)" MaxLength="18" AutoPostBack="true" ValidationGroup="txtCnpj" OnTextChanged="txtCnpj_TextChanged"></asp:TextBox> in the aspx.cs protected void txtCnpj_TextChanged(object sender, EventArgs e) { if (CredorInvestimento.GetCredorInvestimento(txtCnpj.Text) != null) { ((TextBox)sender).Text = ""; ((TextBox)sender).Focus(); rfvCnpj.ErrorMessage = "Duplicado"; Page.Validate(txtCnpj.ID); } else txtNome.Focus(); } Thanks! ps: I really doesn't like of asp.net I spend more time fixing errors than developing new functions. ps: sorry for my english. ps: if i remove the onkeydown and onkeyup events the textchanged fire in IE, but i realy this events too.

    Read the article

  • Selected Index Changed event not firing both Autopostback property

    - by TechGuy
    In my Dropdownlist Selected index change event not firing.Here i use auto post back true & View state also true.But Selected Index Changed Event not firing My Code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdminEagleViewLogin.aspx.cs" Inherits="AdminEagleViewLogin" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <style> body{padding-top:20px;} </style> <title></title> </head> <body> <form id="form1" runat="server"> <div class="container"> <div class="row"> User : <asp:DropDownList ID="drpusr" runat="server" Visible="true" OnSelectedIndexChanged="drpusr_SelectedIndexChanged" AutoPostBack="true" EnableViewState="true" ></asp:DropDownList> Password: <asp:Label ID="lbluserpw" runat="server"></asp:Label> <div class="col-md-4 col-md-offset-4"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Please sign in</h3> </div> <div class="panel-body"> <form accept-charset="UTF-8" role="form"> <fieldset> <div class="form-group"> <asp:TextBox ID="txtusr" runat="server"></asp:TextBox> </div> <div class="form-group"> <asp:TextBox ID="txtpw" runat="server" TextMode="Password"></asp:TextBox> </div> <div class="checkbox"> <label> <input name="remember" type="checkbox" value="Remember Me"> Remember Me </label> </div> <asp:CheckBox ID="chkremember" runat="server" Visible="false" class="remchkbox" /> <asp:Button ID="submit" runat="server" class="btn btn-lg btn-success btn-block" Text="Submit" OnClick="submit_Click" /> </fieldset> </form> </div> </div> </div> </div> </div> </form> </body> </html> ServerSide User bind to Dropdown is working. public partial class AdminEagleViewLogin : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { BindUsers(); //lbluserpw.Text = Membership.Provider.GetPassword(drpusr.SelectedValue, String.Empty); } protected void submit_Click(object sender, EventArgs e) { if (Membership.ValidateUser(txtusr.Text, txtpw.Text)) { FormsAuthentication.SetAuthCookie(txtusr.Text, chkremember.Checked); string[] CurrentUserRole = Roles.GetRolesForUser(txtusr.Text); var admin = "Administrator"; var manager = "Manager"; var user = "User"; if (CurrentUserRole.Contains(admin)) { Response.Redirect("Administrator.aspx"); } else if (CurrentUserRole.Contains(manager)) { Response.Redirect("Manager.aspx"); } else { Response.Redirect("UserPage.aspx"); } } else { Response.Redirect("AdminEagleViewLogin.aspx"); } } protected void BindUsers() { DataAccess da = new DataAccess(); drpusr.DataSource = da.GetUsers(); drpusr.DataTextField = "UserName"; drpusr.DataValueField = "UserId"; drpusr.DataBind(); drpusr.Items.Insert(0, new ListItem("-- Select User --", "0")); drpusr.Items.RemoveAt(1); } protected void drpusr_SelectedIndexChanged(object sender, EventArgs e) { lbluserpw.Text = Membership.Provider.GetPassword(drpusr.SelectedValue, String.Empty); } }

    Read the article

  • autopostback problem listbox asp.net

    - by lodun
    I want to add posts(question) like i do that on yahoo answers.When i choose item in "kategorije" control,items can't be loaded in "SUB_kategorije" control. Image My new ascx.cs: 1. protected void Page_Load(object sender, EventArgs e) 2. { 3. 4. 5. if (!Page.IsPostBack) 6. { 7. 8. SqlDataSource ds = new SqlDataSource(); 9. ds.ConnectionString = conn; 10. ds.SelectCommand = "SELECT [ID], [Kategorije] FROM [kategorije] "; 11. kategorije.DataSource = ds; 12. kategorije.DataTextField = "Kategorije"; 13. kategorije.DataValueField = "ID"; 14. kategorije.DataBind(); 15. kategorije.SelectedIndex = 1; 16. 17. SqlDataSource dk = new SqlDataSource(); 18. dk.ConnectionString = conn; 19. dk.SelectCommand = "SELECT * from pod_kategorije WHERE kat_id = " + kategorije.SelectedItem.Value; 20. SUB_kategorije.DataSource = dk; 21. SUB_kategorije.DataTextField = "pkategorija"; 22. SUB_kategorije.DataValueField = "ID"; 23. SUB_kategorije.DataBind(); 24. 25. 26. } 27. 28. 29. 30. 31. } 32. protected void kategorije_SelectedIndexChanged(object sender, EventArgs e) 33. { 34. 35. 36. SqlDataSource dk = new SqlDataSource(); 37. dk.ConnectionString = conn; 38. dk.SelectCommand = "SELECT * from pod_kategorije WHERE [kat_id] = " + kategorije.SelectedItem.Value; 39. SUB_kategorije.DataSource = dk; 40. SUB_kategorije.DataTextField = "pkategorija"; 41. SUB_kategorije.DataValueField = "ID"; 42. SUB_kategorije.DataBind(); 43. 44. 45. } and .ascx: 1. <asp:ListBox ID="kategorije" runat="server" Height="380px" CssClass="kat" AutoPostBack="true" 2. 3. onselectedindexchanged="kategorije_SelectedIndexChanged"></asp:ListBox> 4. 5. <asp:Button ID="Button1" CssClass="posalji" runat="server" Text="click" 6. onclick="Button1_Click" /> 7. 8. 9. 10. <asp:UpdatePanel ID="UpdatePanel10" runat="server"> 11. <ContentTemplate> <asp:ListBox ID="SUB_kategorije" CssClass="pod" Height="150px" runat="server"></asp:ListBox></ContentTemplate> 12. <Triggers> 13. <asp:AsyncPostBackTrigger ControlID="kategorije" EventName="SelectedIndexChanged" /> 14. 15. </Triggers> 16. 17. </asp:UpdatePanel>

    Read the article

  • Dropdown OnSelectedIndexChanged not firing

    - by Jim
    The OnSelectedIndexChanged event is not firing for my dropdown box. All forums I have looked at told me to add the AutoPostBack="true", but that didn't change the results. HTML: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Current Time: " /> <br /> <asp:Label ID="lblCurrent" runat="server" Text="Label" /><br /><br /> <asp:DropDownList ID="cboSelectedLocation" runat="server" AutoPostBack="true" OnSelectedIndexChanged="cboSelectedLocation_SelectedIndexChanged" /><br /><br /> <asp:Label ID="lblSelectedTime" runat="server" Text="Label" /> </div> </form> </body> </html> Code behind: public partial class _Default : System.Web.UI.Page { string _sLocation = string.Empty; string _sCurrentLoc = string.Empty; TimeSpan _tsSelectedTime; protected void Page_Load(object sender, EventArgs e) { AddTimeZones(); cboSelectedLocation.Focus(); lblCurrent.Text = "Currently in " + _sCurrentLoc + Environment.NewLine + DateTime.Now; lblSelectedTime.Text = _sLocation + ":" + Environment.NewLine + DateTime.UtcNow.Add(_tsSelectedTime); } //adds all timezone displaynames to combobox //defaults combo location to seoul, South Korea //defaults current location to current location private void AddTimeZones() { foreach(TimeZoneInfo tz in System.TimeZoneInfo.GetSystemTimeZones()) { string s = tz.DisplayName; cboSelectedLocation.Items.Add(s); if (tz.StandardName == "Korea Standard Time") cboSelectedLocation.Text = s; if (tz.StandardName == System.TimeZone.CurrentTimeZone.StandardName) _sCurrentLoc = tz.StandardName; } } //changes timezone name and time depending on what is selected in the cbobox. protected void cboSelectedLocation_SelectedIndexChanged(object sender, EventArgs e) { foreach (TimeZoneInfo tz in System.TimeZoneInfo.GetSystemTimeZones()) { if (cboSelectedLocation.Text == tz.DisplayName) { _sLocation = tz.StandardName; _tsSelectedTime = tz.GetUtcOffset(DateTime.UtcNow); } } } } Any advice into what to look at for a rookie asp coder? EDIT: added more code behind

    Read the article

  • RadioButtonList confirm SelectedIndexChange

    - by Brian David Berman
    I have a RadioButtonList control and I would like to do a Javascript "confirm" when a user tries to change the index. Currently AutoPostBack is set to TRUE. I can, of course, just call __doPostBack from within a javascript function, etc. I tried a few things with jQuery but you have to worry about mousedown vs. click and then there is always the fact that you can click the checkbox label to select it, etc. Anyone have a nice solution for this? To be clear, I am looking for a way to prompt the user with a confirm box prior to their selection being made and triggering a postback.

    Read the article

  • Selected Item not being updated?

    - by iTayb
    I've got the following DropDownList control: <asp:DropDownList ID="SubjectFilter" runat="server" AutoPostBack="True" onselectedindexchanged="SubjectFilter_SelectedIndexChanged"></asp:DropDownList> SubjectFilter data: BookStore b = new BookStore(); b.LoadFromXML(Server.MapPath("list.xml")); SubjectFilter.DataSource = b.BooksList.Select(x => x.Subject).Distinct().ToArray(); SubjectFilter.DataBind(); SubjectFilter.Items.Insert(0, new ListItem("???", "Default")); Everything loads just fine. However in the SubjectFilter_SelectedIndexChanged method, SubjectFilter.SelectedValue is always Default, even though I'm selecting different options. What is the problem? Thank you very much.

    Read the article

  • DropdownList autoposback after client confirmation

    - by Aamir
    I have a dropdownlist with the autopostback set to true. I want the user to confirm if they really want to change the value, which on post back fires a server side event (selectedindexchanged). I have tried adding an onchange attribute "return confirm('Please click OK to change. Otherwise click CANCEL?';") but it will not postback regardless of the confirm result and the value in the list does not revert back if cancel selected. When I remove the onchange attribute from the DropdownList tag, the page does postback. It does not when the onchange attribute is added. Do I still need to wire the event handler (I'm on C# .Net 2.0 ). Any leads will be helpful. Thanks!

    Read the article

  • JavaScript "confirm" on SelectedIndexChange of RadioButtonList

    - by Brian David Berman
    I have a RadioButtonList control and I would like to do a Javascript "confirm" when a user tries to change the index. Currently AutoPostBack is set to TRUE. I can, of course, just call __doPostBack from within a javascript function, etc. I tried a few things with jQuery but you have to worry about mousedown vs. click and then there is always the fact that you can click the checkbox label to select it, etc. Anyone have a nice solution for this? To be clear, I am looking for a way to prompt the user with a confirm box prior to their selection being made and triggering a postback.

    Read the article

  • Are the ASP.net __EVENTTARGET and __EVENTARGUMENT susceptible to SQL injection?

    - by Schleichermann
    A security review was done against one of our ASP.net applications and returned in the test results was a SQL Injection Exposures considered to be a high risk item. The test that was performed passed a SQL statement as the value of the __EVENTTARGET and the __EVENTARGUMENT. I am wondering since these 2 values are ASP.net auto-generated hidden fields used for the Auto-Postback feature of the framework and hold information specific to the controls initiating the postback, is there really the potential for SQL injection if you are never manually calling and or pulling values out of these parameters in your code behind?

    Read the article

  • C# GridView dynamically built columns with textboxes ontextchanged

    - by tnriverfish
    My page is a bulk order form that has many products and various size options. I've got a gridview that has a 3 static columns with labels. There are then some dynamically built columns. Each of the dynamically built columns have a textbox in them. The textbox is for quantity. Trying to either update the server with the quantity entered each time a textbox is changed (possibly ontextchanged event) or loop though each of the rows column by column and gather all the items that have a quantity and process those items and their quantities all at once (via button onclick). If I put the process that builds the GridView behind a if(!Page.IsPostBack) then the when a textchanged event fires the gridview only gets the static fields and the dynamic ones are gone. If I remove the if(!Page.IsPostBack) the process to gather and build the page is too heavy on processing and takes too long to render the page again. Some advice would be appreciated. Thanks

    Read the article

  • C# GridView dynamically built columns with textboxes ontextchanged

    - by tnriverfish
    My page is a bulk order form that has many products and various size options. I've got a gridview that has a 3 static columns with labels. There are then some dynamically built columns. Each of the dynamically built columns have a textbox in them. The textbox is for quantity. Trying to either update the server with the quantity entered each time a textbox is changed (possibly ontextchanged event) or loop though each of the rows column by column and gather all the items that have a quantity and process those items and their quantities all at once (via button onclick). If I put the process that builds the GridView behind a if(!Page.IsPostBack) then the when a textchanged event fires the gridview only gets the static fields and the dynamic ones are gone. If I remove the if(!Page.IsPostBack) the process to gather and build the page is too heavy on processing and takes too long to render the page again. Some advice would be appreciated. Thanks

    Read the article

  • HTML form with single text field + preventing postback in Internet Explorer

    - by SudheerKovalam
    I have noticed a rather strange behaviour in IE. I have a HTML form with a single input text field and a submit button On Submit click I need to execute a client side JavaScript function that does the necessary. Now when I want to prevent the postback in the text field (on enter key press) I have added a key press JavaScript function that looks like this: <input type=text onkeypress="return OnEnterKeyPress(event)" /> function OnEnterKeyPress(event) { var keyNum = 0; if (window.event) // IE { keyNum = event.keyCode; } else if (event.which) // Netscape/Firefox/Opera { keyNum = event.which; } else return true; if (keyNum == 13) // Enter Key pressed, then start search, else do nothing. { OnButtonClick(); return false; } else return true; } Strangly this doesn't work. But if I pass the text field to the function : <input type=text onkeypress="return OnEnterKeyPress(this,event);" /> function OnEnterKeyPress(thisForm,event) { var keyNum = 0; if (window.event) // IE { keyNum = event.keyCode; } else if (event.which) // Netscape/Firefox/Opera { keyNum = event.which; } else return true; if (keyNum == 13) // Enter Key pressed, then start search, else do nothing. { OnButtonClick(); return false; } else return true; } I am able to prevent the postback. Can anyone confirm what is exactly happening here?? the HTML form has just one text box and a submit button The resultant o/p of the JavaScript function executed on submit is displayed in a HTML text area in a separate div.

    Read the article

  • VS2010. Dropdownlist Autopostback works in IDE, not when deployed

    - by George
    I have a VS2010 RC ASP.NET web page,when a user changes the drop down selection on an auto postback dropdown, it refreshes a small grid and a few labels in various places on the page. I know wrapping a whole page in a big UpdatePanel control will cause horror from many of you, but that's what I did. I really didn't want a full page refresh and I didn't know how to update a table on the client side using Javascript and I figured it would be a big change. Suggestions for avoiding this are welcomed, but my main desire is to understand teh error I am getting. When I do the auto postbacks in the IDE, everything works fine, but if I deploy the code (IIS 5.5 on XP), the second auto postback works but the seconds one gives me his error. Ajax is one big nasty blackbox to me. Can someone help, please? Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; MS-RTC EA 2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET4.0C; .NET4.0E) Timestamp: Sun, 28 Mar 2010 17:23:23 UTC Message: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object. Line: 796 Char: 13 Code: 0 URI: http://localhost/BESI/ScriptResource.axd?d=3HKc1zGdeSk2WM7LpI9tTpMQUN7bCfQaPKi6MHy3P9dace9kFGR5G-jymRLHm0uxZ0SqWlVSWl9vAWK5JiPemjSRfdtUq34Dd5fQ3FoIbiyQ-hcum21C-j06-c0YF7hE0&t=5f011aa5 Message: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object. Line: 796 Char: 13 Code: 0 URI: http://localhost/BESI/ScriptResource.axd?d=3HKc1zGdeSk2WM7LpI9tTpMQUN7bCfQaPKi6MHy3P9dace9kFGR5G-jymRLHm0uxZ0SqWlVSWl9vAWK5JiPemjSRfdtUq34Dd5fQ3FoIbiyQ-hcum21C-j06-c0YF7hE0&t=5f011aa5 Message: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object. Line: 796 Char: 13 Code: 0 URI: http://localhost/BESI/ScriptResource.axd?d=3HKc1zGdeSk2WM7LpI9tTpMQUN7bCfQaPKi6MHy3P9dace9kFGR5G-jymRLHm0uxZ0SqWlVSWl9vAWK5JiPemjSRfdtUq34Dd5fQ3FoIbiyQ-hcum21C-j06-c0YF7hE0&t=5f011aa5

    Read the article

  • No Change for Index of DropDownList in a Custom Control!!!

    - by mahdiahmadirad
    Hi Dears, I have Created A Custom Control which is a DropDownList with specified Items. I designed AutoPostback and SelectedCategoryId as Properties and SelectedIndexChanged as Event for My Custom Control. Here Is My ASCX file Behind Code: private int _selectedCategoryId; private bool _autoPostback = false; public event EventHandler SelectedIndexChanged; public void BindData() { //Some Code... } protected void Page_Load(object sender, EventArgs e) { BindData(); DropDownList1.AutoPostBack = this._autoPostback; } public int SelectedCategoryId { get { return int.Parse(this.DropDownList1.SelectedItem.Value); } set { this._selectedCategoryId = value; } } public string AutoPostback { get { return this.DropDownList1.AutoPostBack.ToString(); } set { this._autoPostback = Convert.ToBoolean(value); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (SelectedIndexChanged != null) SelectedIndexChanged(this, EventArgs.Empty); } I Want Used Update Panel to Update Textbox Fields According to dorp down list selected index. this is my code in ASPX page: <asp:Panel ID="PanelCategory" runat="server"> <p> Select Product Category:&nbsp; <myCtrl:CategoryDDL ID="CategoryDDL1" AutoPostback="true" OnSelectedIndexChanged="CategoryIndexChanged" SelectedCategoryId="0" runat="server" /> </p> <hr /> </asp:Panel> <asp:UpdatePanel ID="UpdatePanelEdit" runat="server"> <ContentTemplate> <%--Some TextBoxes and Other Controls--%> </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID="CategoryDDL1" /> </Triggers> </asp:UpdatePanel> But Always The Selected Index of CategoryDDL1 is 0(Like default). this means Only Zero Value will pass to the event to update textboxes Data. what is the wrong with my code? why the selected Index not Changing? Help?

    Read the article

  • SelectedIndexChanged for programmatically created dropdownlist in ASP.NET fires multiple times.

    - by Achilles
    Consider the following: dim dropdownlist1 as new dropdownlist dim dropdownlist2 as new dropdownlist dim dropdownlist3 as new dropdownlist dropdownlist1.AutoPostBack = true dropdownlist2.AutoPostBack = true dropdownlist3.AutoPostBack = true AddHandler dropdownlist1.SelectedIndexChanged, AddressOf SomeEvent AddHandler dropdownlist2.SelectedIndexChanged, AddressOf SomeEvent AddHandler dropdownlist3.SelectedIndexChanged, AddressOf SomeEvent The SomeEvent fires as expected when any of the dropdown's selection is changed. However if say DropdownList2 has a selection made then I make a selection with either DropDownList1 or DropdownList3, then SomeEvent fires again. What is causing this behavior and how do I get just a single raising of that event? I suspect that when the viewstate for the dynamcially created dropdownlists is restored and the selection restored, then the event is fired because technically the selected index did change when the control was recreated. The reason I suspect this is that the event fires the for each dropdownlist...

    Read the article

  • Add Event Handler To Dynamic Dropdownlist

    - by Andrea Girardi
    Hi all! I have a page that contains dynamically generated Dropdown List controls and I want thant the dynamic dropdown list perform an AutoPostback to fill some other field using the value selected. This is the code I'm using to create dynamically the control: If (Not IsPostBack) Then Dim newDDL As DropDownList = New DropDownList() AddHandler newDDL.SelectedIndexChanged, AddressOf ChangeValue newDDL.ID = "Level1" [fill the DropDownList] newDDL.Items.Insert(results.Count, New ListItem("", -1)) newDDL.Width = "300" newDDL.AutoPostBack = True newDDL.SelectedIndex = results.Count LevelDDLs.Controls.Add(newDDL) LevelDDLs.Controls.Add(New LiteralControl("<br /><br />")) End If Control is correctly filled and rendered on ASP page but, after selecting a value, the page is reloaded (AutoPostBack is called) but the control is not diplayed and the sub is not called. I put a breakpoint into the ChangeValue sub but anything happens. I read on some post that handler for the first DropDownList is not necessary but, how is it possible to tell DropDownList to call my sub after changevalue? Could you help me, please? many thanks, Andrea

    Read the article

  • ASP.NET TextBox verses input type="text" behavior

    - by harrije
    I notice with ASP.NET if the server side control TextBox is used with out autopostback it will not submit (or postback) the form when typed text ends with enter, which is different from the behavior for plain old HTML pages. Fine, I can set autopostback to get the behavior I want after the enter key. However, autopostback will also cause submit (or postback) when the typed text does not end with enter but focus has changed (i.e. with tab or mouse click), which again is different from plain old HTML pages. How can I get an ASP.NET page to behave the same as a plain old HTML page with respect to text input regardless of whether enter key or change of focus occurs?

    Read the article

  • Using Unity – Part 6

    - by nmarun
    This is the last of the ‘Unity’ series and I’ll be talking about generics here. If you’ve been following the previous articles, you must have noticed that I’m just adding more and more ‘Product’ classes to the project. I’ll change that trend in this blog where I’ll be adding an ICaller interface and a Caller class. 1: public interface ICaller<T> where T : IProduct 2: { 3: string CallMethod<T>(string typeName); 4: } 5:  6: public class Caller<T> : ICaller<T> where T:IProduct 7: { 8: public string CallMethod<T>(string typeName) 9: { 10: //... 11: } 12: } We’ll fill-in the implementation of the CallMethod in a few, but first, here’s what we’re going to do: create an instance of the Caller class pass it the IProduct as a generic parameter in the CallMethod method, we’ll use Unity to dynamically create an instance of IProduct implemented object I need to add the config information for ICaller and Caller types. 1: <typeAlias alias="ICaller`1" type="ProductModel.ICaller`1, ProductModel" /> 2: <typeAlias alias="Caller`1" type="ProductModel.Caller`1, ProductModel" /> The .NET Framework’s convention to express generic types is ICaller`1, where the digit following the "`" matches the number of types contained in the generic type. So a generic type that contains 4 types contained in the generic type would be declared as: 1: <typeAlias alias="Caller`4" type="ProductModel.Caller`4, ProductModel" /> On my .aspx page, I have the following UI design: 1: <asp:RadioButton ID="LegacyProduct" Text="Product" runat="server" GroupName="ProductWeb" 2: AutoPostBack="true" OnCheckedChanged="RadioButton_CheckedChanged" /> 3: <br /> 4: <asp:RadioButton ID="NewProduct" Text="Product 2" runat="server" GroupName="ProductWeb" 5: AutoPostBack="true" OnCheckedChanged="RadioButton_CheckedChanged" /> 6: <br /> 7: <asp:RadioButton ID="ComplexProduct" Text="Product 3" runat="server" GroupName="ProductWeb" 8: AutoPostBack="true" OnCheckedChanged="RadioButton_CheckedChanged" /> 9: <br /> 10: <asp:RadioButton ID="ArrayConstructor" Text="Product 4" runat="server" GroupName="ProductWeb" 11: AutoPostBack="true" OnCheckedChanged="RadioButton_CheckedChanged" /> Things to note here are that all these radio buttons belong to the same GroupName => only one of these four can be clicked. Next, all four controls postback to the same ‘OnCheckedChanged’ event and lastly the ID’s point to named types of IProduct (already added to the web.config file). 1: <type type="IProduct" mapTo="Product" name="LegacyProduct" /> 2:  3: <type type="IProduct" mapTo="Product2" name="NewProduct" /> 4:  5: <type type="IProduct" mapTo="Product3" name="ComplexProduct"> 6: ... 7: </type> 8:  9: <type type="IProduct" mapTo="Product4" name="ArrayConstructor"> 10: ... 11: </type> In my calling code, I see which radio button was clicked, pass that as an argument to the CallMethod method. 1: protected void RadioButton_CheckedChanged(object sender, EventArgs e) 2: { 3: string typeName = ((RadioButton)sender).ID; 4: ICaller<IProduct> caller = unityContainer.Resolve<ICaller<IProduct>>(); 5: productDetailsLabel.Text = caller.CallMethod<IProduct>(typeName); 6: } What’s basically happening here is that the ID of the control gets passed on to the typeName which will be one of “LegacyProduct”, “NewProduct”, “ComplexProduct” or “ArrayConstructor”. I then create an instance of an ICaller and pass the typeName to it. Now, we’ll fill in the blank for the CallMethod method (sorry for the naming guys). 1: public string CallMethod<T>(string typeName) 2: { 3: IUnityContainer unityContainer = HttpContext.Current.Application["UnityContainer"] as IUnityContainer; 4: T productInstance = unityContainer.Resolve<T>(typeName); 5: return ((IProduct)productInstance).WriteProductDetails(); 6: } This is where I’ll resolve the IProduct by passing the type name and calling the WriteProductDetails() method. With all things in place, when I run the application and choose different radio buttons, the output should look something like below:          Basically this is how generics come to play in Unity. Please see the code I’ve used for this here. This marks the end of the ‘Unity’ series. I’ll definitely post any updates that I find, but for now I don’t have anything planned.

    Read the article

1 2 3 4 5 6 7  | Next Page >