So, i'm new to ASP.NET and AJAX.
I am trying out the Beta library.
I setup a page and was using the Editor.
The loading of this page is well, slow.
There is nothing more than then, you can see it here
http://eski.internet.is/default.aspx but it will take a min to load.
Whats is the reason for the slow load, is it the AJAX library ?
Its about 7 mb, the .dll's. Is it downloading it everytime you load the page ?
No, it doesn't load the whole 7mb worth of .dlls - that's the code that generates the output.
For that site I'm getting this from YSlow:
HTTP Requests - 46
Total Weight - 304.9K
1 HTML/Text 121.9K
4 JavaScript File 161.7K
3 Stylesheet File 6.4K
38 Image 14.7K
Which isn't that much. It did seem to take a LONG time for the host to respond, however. What are the specs on your server and its internet connection?
In your web.config do you have debug="true"? If so, take that out as it can cause pages to take longer as it then generates debug information.
It doesn't seem to be hanging on any one component being served to the client. It seems to be either server load or something in your code. Can you provide the code that you are using to better help diagnose this?
This is the code that website http://eski.internet.is/default.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit.HTMLEditor" tagprefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" ScriptMode="Release"></asp:ToolkitScriptManager>
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:DropShadowExtender ID="TextBox1_DropShadowExtender" runat="server"
Enabled="True" TargetControlID="TextBox1">
</asp:DropShadowExtender>
<asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
Enabled="True" TargetControlID="TextBox1">
</asp:CalendarExtender>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="To Editor" />
<br />
<br />
<cc1:Editor ID="Editor1" runat="server" Width="500" />
<br />
<asp:Button ID="Button2" runat="server" Text="To Textbox"
onclick="Button2_Click" />
<br />
<br />
<asp:TextBox ID="TextBox2" runat="server" Height="161px" TextMode="MultiLine"
Width="600px"></asp:TextBox>
</form>
</body>
</html>
Related
I was trying to use a calendar extender but for some reasons it not working?
Just put a simple TextBox and CalendarExtender, when I click inside the textbox it supposed to be popup the calendar, but I got nothing.
On the other hand, I tried the ConfirmButtonExteder and it work fine.
I don't know if something wrong, maybe I missing something in web.config? but why the ConfirmButtonExtender works?
I use VS 2012, ASP.NET C#, .NET Framework 4.5, Ajax toolkit 4.1.7.725 (latest one from official website) then Install the Ajaxtoolkit it from Nuget (version 4.5...) but still samething, the calendar is not popup, the confirmbuttonextender works just fine. I dont know why?
Here my code:
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="MainContent">
<p>
<ajaxToolkit:ToolkitScriptManager runat="server" ID="ScriptManager1" /
<asp:Button ID="Button1" runat="server" Text="Button" />
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button1"></ajaxToolkit:ConfirmButtonExtender>
<br />
<asp:TextBox runat="server" ID="Date1"/>
<br />
<ajaxToolkit:CalendarExtender ID="defaultCalendarExtender" runat="server" TargetControlID="Date1" />
</p>
</asp:Content>
Here's what you can do:
Check that AjaxControlToolkit.dll and AjaxControlToolkit.pdb are in your Bin Folder.
Place the assembly
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> above the page.
Make sure the ScriptManager is below the BodyContent of ContentPlaceHolder
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Double-Check the TagPrefix and the TargetControlID of the CalendarExtender
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1">
<%# Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" ClientIDMode="AutoID" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="server">
<%
foreach (var item in AllSales)
{
//Here i have just set a breakpoint to see if it loops the AllSales list when I press the update button
}
%>
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<p>Update Panel: DateTime.Now: <%= DateTime.Now.ToString() %></p>
<asp:Button runat="server" ID="Submit" Text="Update" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
The script manager code is in the masterpage :
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
Problem here is that everytime i click the Update button it loads the page again and loops the "AllSales" list , i want to only update a section and not have to do unnecessary loops.
Here is the fun part : If i remove the masterpage, it works ! But with the masterpage, it dont , why?!
You need to use a server control to initiate the update rather than a normal html input button. Try using:
<asp:Button ID="ActivitySubmit" Text="Submit" runat="server" />
The reason for such behavior is that you use plain html submit button instead of ASP.NET server button. Thus page submitted to server without involving ASP.NET Ajax functionality. Replace ActivitySubmit button with asp:Button control
Set the UpdateMode mode property to Conditional. The default value for UpdateMode is Always, If the UpdateMode property is set to Always, the UpdatePanel control's content is updated on every postback that originates from anywhere on the page, reference
Edit: You are using input type="submit" which probably causing the post back replace it with asp:Button to get the ajax call to work.
I have tested the same code with only change in the button type, and it refreshes only the update panel content. The problem is your site is targeting .NET 3.0 but you need to target at least to 3.5. I have tested on 3.0, it does not work but on 3.5 and 4.0, it works fine. So the easier and safer solution is to target 3.5 onwards. But If you want to use .NET 3.0, I will try to find a workaround. Please let me know.
I tried to recreate your problem but it is working fine in my case. Try creating a new .aspx file and paste the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Outside UpdatePanel</p>
<asp:ScriptManager runat="server" ID="ScriptManager1">
</asp:ScriptManager>
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<p>DateTime.Now: <%= DateTime.Now.ToString() %></p>
<asp:Button runat="server" ID="SubmitButton" Text="Go" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
This was tested in VS2010 using .NET 4.0 in an Empty Web Application. Does this work for you as well? I tried the same example using a Master page with a content placeholder. This yields the same (properly working) results. From this I gather there is something else going on on your page that we're missing. Is there?
[Edit]
I made another simple example, this time with a Master page and a Content page.
Master page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
<p>Master Page: DateTime.Now: <%= DateTime.Now.ToString() %></p>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Aspx page:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<p>Update Panel: DateTime.Now: <%= DateTime.Now.ToString() %></p>
<asp:Button runat="server" ID="Submit" Text="Update" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Again this works without a problem in the same environment as the other example. It looks like you'll have to tell me about the .NET framework you're targeting and what else you've got set up in your master page and aspx page, because:
In .Net 3.5 and up this will work. In lower versions however, it won't. I'm afraid I've been unable to figure out how to fix it in lower versions though. :(
In your Page tag just add
ClientIDMode="AutoID"
I think you can try and put the form inside the updatepanel, or you can try and change children as triggers property of the updatepanel like this :
<asp:UpdatePanel runat="server" ID="UpdatePanel1" ChildrenAsTriggers="False">
and then add the button as trigger like this
ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(SubmitButton);
try addind this part to your UpdatePanel:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Submit" />
</Triggers>
I am trying to do an ajax website, but my ajax is not working. I checked my GAC and system.web,extensions dll is available.
Why it is not working .? I am also not getting any errors. I tried many ways.
I wrote the below code to test ajax.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%# Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1">
</cc1:CalendarExtender>
</div>
</form>
</body>
</html>
JAvascript error that i got
1.Type is not defined
http://localhost:1467/testnew/Default.aspx?_TSM_HiddenField_=ToolkitScriptManager1_HiddenField&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d1.0.20229.20821%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aen-US%3ac5c982cc-4942-4683-9b48-c2c58277700f%3ae2e86ef9%3aa9a7729d%3a9ea3f0e2%3a9e8e87e9%3a1df13a87%3a4c9865be%3aba594826%3a507fcf1b%3ac7a4182e
You have to make sure ajax 1.0.20229.20821 is registered on your machine before trying to use the controls
You can find it here: http://msdn.microsoft.com/en-us/library/bb861898(v=office.12).aspx
I need help how to fix the error in my code. When I compile the code told me the error Validation (XHTML 1.0 Transitional): Element 'html' cannot be nested within element 'div'. If someone know, please help me?
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ManageUsers.aspx.cs" Inherits="probazaadmin.ManageUsers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form2" runat="server"></form>
<div>Users Account Management</div>
<p></p>
<b>- The total registered users is: <asp:Literal runat="server" ID="lblTotalUsers" /><br />
- The total online users at this moment: <asp:Literal runat="server" ID="lblOnlineUsers" /></b>
<p></p>
In order to display all users whose name begins with letter click on the link letter:
<p></p>
<asp:Repeater runat="server" ID="rptAlphabetBar"
OnItemCommand="rptAlphabetBar_ItemCommand">
<ItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Container.DataItem %>'
CommandArgument='<%# Container.DataItem %>' />
</ItemTemplate>
</asp:Repeater>
<p></p>
Use the below feature to search users by partial username or e-mail:
<p></p>
<asp:DropDownList runat="server" ID="ddlUserSearchTypes">
<asp:ListItem Text="UserName" Selected="true" />
<asp:ListItem Text="E-mail" />
</asp:DropDownList>
contains
<asp:TextBox runat="server" ID="txtSearchText" />
<asp:Button runat="server" ID="btnSearch" Text="Search"
OnClick="btnSearch_Click" />
</body></html>
</asp:Content>
Your code shows you are:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master"....
using a master page (which is where the HTML declaration is)
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
using the content page placeholder to add and entire HTML document - which you shouldn't do.
as stated, the master page is where HTML declarations go
ASP.net content sections are for content only.
Your code should be like this
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ManageUsers.aspx.cs" Inherits="probazaadmin.ManageUsers" %>
Users Account Management
- The total registered users is:
- The total online users at this moment:
In order to display all users whose name begins with letter click on the link letter:
<asp:Repeater runat="server" ID="rptAlphabetBar"
OnItemCommand="rptAlphabetBar_ItemCommand">
<ItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Container.DataItem %>'
CommandArgument='<%# Container.DataItem %>' />
</ItemTemplate>
</asp:Repeater>
<p></p>
Use the below feature to search users by partial username or e-mail:
<p></p>
<asp:DropDownList runat="server" ID="ddlUserSearchTypes">
<asp:ListItem Text="UserName" Selected="true" />
<asp:ListItem Text="E-mail" />
</asp:DropDownList>
contains
<asp:TextBox runat="server" ID="txtSearchText" />
<asp:Button runat="server" ID="btnSearch" Text="Search"
OnClick="btnSearch_Click" />
</asp:Content>
Hi all I have an update panel that works lovely in my test solution but when I put it into the main project it does not work correctly.
I've made it very simple, but still no joy, it consists of:
the file upload control
a link button
the link button has an onclick method that takes the file and creates a byte array. For some reason the contentLength is -2 every time. It does not matter what type of file I am using. Every time!
This is very frustrating considering it works fine in my test solution.
Is there anything I am missing or should be looking at?
Thanks :)
EDIT:
I am using VS2008
CODE:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:LinkButton ID="btnUpload" runat="server" ValidationGroup="uploadform" CssClass="uploadbutton" OnClick="btnUpload_Click">Upload</asp:LinkButton>
</form>
</body>
</html>
C#
protected void btnUpload_Click(object sender, EventArgs e)
{
var intDoccumentLength = FileUpload1.PostedFile.ContentLength;
// will crash here as content length is -2 for some reason~???
byte[] newDocument = new byte[intDoccumentLength];
}
Your test code must be doing complete postback which is not the case for Updatepanel part as part of main project. With updatepanel, file may not have been uploaded at point of time when you are checking its contentlenght; this is not true for complete postback where file always gets uploaded first. In this case, it will always through you an error. This can only be done using an ActiveX control of some kind.
This article may give you nice hint and direction: asp.net FileUpload event after choice is made and before submit for upload
The file up loader is not working well in the update panel so if you are using the update panel then you have to use the triggers in the update panel and you have to give the name of the control or button on which you are clicking to upload the file
<%# Page Language="C#" MasterPageFile="~/FullViewMasterPage.master" AutoEventWireup="true" CodeFile="Test1.aspx.cs" Inherits="Test1" Title="Untitled Page" %>
<%# Register TagPrefix="yaf" Namespace="YAF" Assembly="YAF" %>
<%# Register TagPrefix="yc" Namespace="YAF.Controls" Assembly="YAF" %>
<asp:Content ID="Content1" ContentPlaceHolderID="FullViewContentPlaceHolder" Runat="Server">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FileUpload id="fileUpload" runat="server" ></asp:FileUpload>
<asp:Button ID="Upload" runat="server" OnClick="Upload_Click" Text="Upload The Image" /><br />
</ContentTemplate>
</asp:UpdatePanel>
<br />
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Upload" EventName="Upload_Click" />
</Triggers>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="lblTime3" runat="server" /><br />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</asp:Content>
<code>
As FileUpload.PostedFile.InputStream.Length returns the same as FileUpload.PostedFile.ContentLength, did you check that your file size is lower than maxRequestLength (4MB by default) or specified in web.config :
<system.web>
<httpRuntime maxRequestLength="8192"/>
</system.web>
See : http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.maxrequestlength.aspx