combobox items not displaying - asp.net

This question has been asked here before, but the author wasn't very clear and got no answers (1st ref). Why aren't my combobox items displaying correctly? It is almost like they are there, but not connected to the combobox (notice my label, it shows up halfway down the page instead of right underneath the combobox when I run it). I get no errors on the page, which is good (different than when I tried doing this in VS2005), and the combobox displays fine, but when I click it, nothing is there.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:ComboBox ID="ComboBox1" runat="server" AutoPostBack="true"
DropDownStyle="DropDownList">
<asp:ListItem>thisis</asp:ListItem>
<asp:ListItem>mynetwork</asp:ListItem>
<asp:ListItem>getoffmyjunk</asp:ListItem>
<asp:ListItem>itsmine</asp:ListItem>
<asp:ListItem>illkillyou</asp:ListItem>
<asp:ListItem>forrealz</asp:ListItem>
<asp:ListItem>what</asp:ListItem>
<asp:ListItem>didyousaysomething</asp:ListItem>
<asp:ListItem>didn'tthinkso</asp:ListItem>
<asp:ListItem>meh</asp:ListItem>
</asp:ComboBox>
<br />
<asp:Label ID="lbl" runat="server">default text</asp:Label>
</div>
</form>
</body>
</html>
https://stackoverflow.com/questions/4322922/combo-box-items-does-not-display-below-of-combo-box-why
I'm having the same problem as this guy:
http://p2p.wrox.com/book-asp-net-ajax-programmers-reference-asp-net-2-0-asp-net-3-5-isbn-978-0-470-10998-4/80267-ajax-combobox-not-displaying-item-list-correctly.html

Your syntax looks to be incorrect for the ComboBox control. You want to use the Text and Value parameters in order to get the options to display. You'll want it to look like this:
<asp:ComboBox ID="ComboBox1" runat="server" AutoPostBack="true" DropDownStyle="DropDownList">
<asp:ListItem Text="thisis" Value="thisis"></asp:ListItem>
<asp:ListItem Text="mynetwork" Value="mynetwork"></asp:ListItem>
<asp:ListItem Text="getoffmyjunk" Value="getoffmyjunk"></asp:ListItem>
</asp:ComboBox>
Note: You may also be running into issues with your control tag declaration. For example, when I import the AJAX Control Toolkit into my applications, and add the proper references, I wind up using the tag "cc1" for all of the AJAX Control Toolkit controls. You may need to double check these references as well.

Use toolkitscriptmanager xDwanted to give the answer to Tim, but he won't put his comment as an answer ;;

Related

JavaScript Error in Microsoft Edge with Telerik RadDatePicker in ASP.NET UpdatePanel

Telerik RadDatePicker inside ASP.NET UpdatePanel in Microsoft Edge browser throws JavaScript error when doing a post-back.
The error: "Unable to get property 'length' of undefined or null reference".
The RadDatePicker must be inside an UpdatePanel for the error to be thrown, and this ONLY happens in Microsoft Edge browser, all other browsers have no error.
Microsoft Edge version: 44.17763.1.0
Telerik Controls: Telerik.Web.UI, Version=2019.1.409.45
Any ideas how to fix this, or a work-around?
Here is my code:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EdgeDatePickerIssue.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Default</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager" runat="server" ScriptMode="Release" />
<asp:UpdatePanel runat="server" ID="upPanel">
<ContentTemplate>
<label>Select Date:</label>
<telerik:RadDatePicker ID="dpStartDate" runat="server"
AutoPostBack="true"
OnSelectedDateChanged="dpStartDate_SelectedDateChanged" />
<telerik:RadButton ID="btnSave" runat="server"
Text="Save" OnClick="btnSave_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Here is a screen-shot of the error:
Screen-shot Error in Edge
The problem is fixed in R2 2019.
Another way to solve it is setting the RadDatePicker's RenderMode property to Lightweight.
You could try to use Telerik RadScriptManager and Telerik RadAjaxPanel instead of using asp.net ScriptManager and UpdatePanel. Then, refer to this article to use DatePicker control.

asp:Menu stops working after a different control performs partial AJAX postback

This issue occurs in ASP.NET 4.6 and I've seen a few similar posts, but they usually referred not to the same control (built-in here) or ended up with a conclusion "just use a different/external control here: html link", which is not really an option for me.
First, some code
Site.Master
<div id="HeaderProper">
<div id="HeaderProperTitle">
<asp:Menu ID="HeaderProperMenu" runat="server" DataSourceID="HeaderProperSiteMap" Orientation="Horizontal"
BackColor="#ff2400"
RenderingMode="List"
StaticEnableDefaultPopOutImage="false"
StaticDisplayLevels="2"
StaticHoverStyle-BackColor="#000000"
StaticMenuItemStyle-HorizontalPadding="15px"
StaticMenuItemStyle-Height="42px"
DynamicHoverStyle-BackColor="#000000"
DynamicMenuItemStyle-HorizontalPadding="5px"
DynamicMenuItemStyle-BackColor="#ff2400"
DynamicMenuItemStyle-Font-Size="24px"/>
<asp:SiteMapDataSource ID="HeaderProperSiteMap" runat="server" />
</div>
SomePage.aspx
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h1>Complete List</h1>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="SortOrderSelection">
Sort by
<asp:DropDownList ID="cbxSortBy" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="cbxSortBy_SelectedIndexChanged" />
</div>
<asp:Panel ID="SortedList" CssClass="top-margin five-columns" runat="server" />
<asp:Panel ID="Summary" CssClass="top-margin" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
How to reproduce:
Choose an item in the DropDownList, which causes partial postback. The menu then stops working, that is - the drop down/hover menu doesn't open, but the first level links seem to be functional. Refreshing the whole page fixes the problems (duh?).
And, contrary to what I've found:
1) Menu is NOT inside an UpdatePanel, which I acknowledge is unsupported solution
2) Menu works fine when RenderingMode is set to Table, but generates a very ugly html code, which I would like to avoid. Not mentioning additional quirks in margins that have to be adjusted with ugly fixes.
3) I tried setting z-index: 1000...0 !important as suggested by some sources (on most menu related styles), but to no avail.
I would be grateful for any suggestions how this can be resolved while still using asp:Menu control in List rendering mode, possibly with as least intervention as possible. My point here is to use built-in functionality and keep the code clean from unnecessary JS, jQuery (if possible at all; otherwise I'd rather open a Connect case for this issue).
Thank you in advance.
Putting your menu into an update panel should work because it will indicate to the server to update it after the postback. Without this, any repost can create the risk of losing some events in your element. Refreshing works because you are refreshing the whole page and not only some element of it.

why my ajax control doesn't work, even no error?

i ahve tried what ever i can to put ajax calender extender in project but it doesn't show, calender never appears,
why ?
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScrptManager" runat="server"></asp:ScriptManager>
<asp:TextBox ID="txtBox" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" TargetControlID="txtBox" runat="server"></asp:CalendarExtender>
</div>
</form>
</body>
</html>
no error, 1st i download ajaxtoolkit for .net 4.5 then i added AJAX tab to tools then i right clicked AJAX tab and selected CHOOSE ITEMS and added these tools to project and then this code
You can replace the scriptManager in the page with
<Ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/> .
This will certainly solve your problem.

ScriptManager required even though it is present

i am getting following error when i am running AJAX enabled ASP.Net application
The control with ID 'FilteredTextBoxExtender1' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
even though i have ScriptManager in my page
what wrong i am doing please give suggestions
thanks in advance
<form id="form1" runat="server">
<asp:scriptmanager id="ScriptManager1" runat="server" />
<div>
<cc1:filteredtextboxextender id="FilteredTextBoxExtender1" targetcontrolid="textbox1"
filtertype="Numbers" runat="server"> </cc1:filteredtextboxextender>
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
</div>
</form>
What version of the toolkit? With recent versions at the time of writing, you need to use toolkitscriptmanager instead of the "normal" scriptmanager.
Place ScriptManager right before UpdatePanel

Unable to get ASP.Net UpdateProgress to display

I'm trying to display an update progress loading image whenever my update panel does it's Ajax thing. I've looked around at tutorials and it seems really straightforward but I'm having no luck. Here is pretty much what I have...
<div id="panelWrapper">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdateProgress ID="TaskUpdateProgress" runat="server" DynamicLayout="False" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="0">
<ProgressTemplate>
<asp:Image ImageUrl="~/Images/ajax-loader.gif" Width="16px" Height="16px" runat="server" ID="TaskLoadingImage"/>
</ProgressTemplate>
</asp:UpdateProgress>
<div id="UrlDiv" class="URLNotification">
<asp:Label ID="UrlLabel" runat="server" Text="URL:" AssociatedControlID="Url" />
<asp:HyperLink ID="Url" runat="server" Text="Click &quotGenerate" to create the URL." />
</div>
<br />
<asp:CheckBoxList runat="server" ID="IncludeItems" TextAlign="Right">
<asp:ListItem Selected="True">Include 1</asp:ListItem>
<asp:ListItem Selected="True">Include 2</asp:ListItem>
</asp:CheckBoxList>
<br />
<div id="buttons" style="display:inline;">
<asp:Button ID="Generate" runat="server" OnClicked="Generate_Clicked" Text="Generate" />
<asp:Button ID="Add" runat="server" OnClientClick="add();" Text="Add"/>
</div>
</ContentTemplate>
</asp:UpdatePanel>
I also have some absolute positioning styling in a stylesheet. I've tried a bunch of variations of what you see here and have not found much good information as to what may be the issue. Any ideas? If you need anything else, let me know.
EDIT: The only new information I've found is that...
"In the following scenarios, the UpdateProgress control will not display automatically:
The UpdateProgress control is associated with a specific update panel, but the asynchronous postback results from a control that is not inside that update panel.
The UpdateProgress control is not associated with any UpdatePanel control, and the asynchronous postback does not result from a control that is not inside an UpdatePanel and is not a trigger. For example, the update is performed in code."
I'm pretty confident neither of these fit into my case. All that is happening is the button (which is inside the update panel) is clicked calling some code behind which set's the URL text to be reloaded for the update panel.
I have also the same problem with the UpdateProgressPanel.
I found out that when you have placed an UpdateProgressPanel and associated it to an UpdatePanel, any postback from that UpdatePanel will cause the UpdateProgressPanel to show.
Another trick to do is to remove the AssociatedUpdatePanel parameter if you have a single UpdatePanel on the page, this will cause the UpdateProgressPanel to show every Async PostBack that happens.
UpdateProgressPanel can be placed anywhere in the code, except those areas that have predefined tags on it. It can be placed inside or outside the UpdatePanel and it will show if you have properly placed its CSS, Associated it to an UpdatePanel or just place it there and it will show up if an async postback result happens.
Don't put the update progress control inside the update panel control
Make sure the UpdateProgress 'DisplayAfter' is set up to 1000 (1 sec)
I guess I figured out what was going on. The issue wasn't with anything I was doing wrong with the UpdateProgress or Panel. It was that I had other stuff loading in the background that was apparently holding up the UpdatePanel's Ajaxyness.
So basically what happened was that the loading icon wouldn't show up on the initial page load. I realized this because I actually waited till after everything on the page was completely loaded to fire off the button. Sure enough the loader showed up.
I assumed that the update panel refresh would at least be requested the instant the click event was heard so the loader icon would immediately show during the time other stuff is loading. This doesn't appear to be the case though...
I was having really hard time after converting my project from VS2008 to VS2010. The UpdateProgress stopped working suddenly, which was fine in VS2008. Spending a whole afternoon to search the answer and experimenting this and that, finally I found what went wrong from Scott Gu's posting.
It was an automatically generated web.config entry 'xhtmlConformance mode="Legacy"'.
After disabling this, it started to work again. May be not the case for you but just for guys struggling with the same problem.
Happy coding
I also had a problem with the UpdateProgress not showing. Turned out the postback to the server was actually so fast it never had time to show. Adding a Thread.Sleep(10000) helped show the problem.
Create a new ASP.NET Ajax-Enabled Web Site and then paste these code in ascs and aspx file. Run it and you can see the update progress. You can use animated gif files too to show the progress...
ascx Page:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>UpdateProgress control</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdateProgress runat="server" id="PageUpdateProgress" AssociatedUpdatePanelID="Panel">
<ProgressTemplate>
Loading...
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel runat="server" id="Panel">
<ContentTemplate>
<asp:Button runat="server" ID="UpdateButton" OnClick="UpdateButton_Click" Text="Update" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateButton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html>
aspx Page:
protected void UpdateButton_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}

Resources