ASP Ajax control toolkit calender extender not displayed properly - asp.net

ASP Ajax control toolkit Calender extender is not appearing properly. Only text values are appearing and looks like CSS is not applied. I tried to disable all the CSS definitions for the page but still it is not being displayed properly.
<%# Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeBehind="DataDownload.aspx.cs" Inherits="myapp.DataDownload" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="head_content" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="body_content" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TextBox ID="txtFromDate" CssClass="inp-form" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="calFromDate" runat="server" TargetControlID="txtFromDate" >
</asp:CalendarExtender>
</asp:Content>

Try commenting Existing Js files on page.
reason : simple, As we know ajax on [page load complete] method makes javascript Code on the fly , which conflicts with existing javascript/jquery on the page, which results on malfunction of either functionality.

Related

Loading ContentPlaceHolders from separate files

I am trying to create a Main.master page with two ContentPlaceHolder sections.
When I load the default page, it only renders ContentPlaceHolder1, I have to actually load Second.aspx to see the second ContentPlaceHolder. Why?
In my Main.master I have:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="Main" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
<asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server"></asp:ContentPlaceHolder>
</div>
</body>
</html>
Additionally, I have created two additional pages Default.aspx and Second.aspx:
Detault:
<%# Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
HOW HOW HOW HOW
</asp:Content>
Other page is
Second:
<%# Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Second.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
COW COW COW COW
</asp:Content>
Its only rendering the first PlaceHolder, how can I have separate content files and have the both rendered on the same page?
You have to ask yourself: If you navigate to Default.aspx, how will your application know to grab the content in Second.aspx? Simply put: it won't.
First, here's the MSDN on the ContentPlaceHolder.
You can have as many ContentPlaceHolders on your masterpage as you want, and EACH page can either render into these content areas or NOT.
So your Default.aspx can look like:
<%# Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
HOW HOW HOW HOW
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
COW COW COW COW
</asp:Content>
And you will get the results you are looking for.
Now, there are ways you can render an OUTSIDE html file INTO one of these content placeholders (one way would be javascript) - but (and please, someone correct me if I'm wrong) there won't be a way to do it with an ASPX webpage, codebehind or not.
To touch on your question:
how can I have separate content files and have the both rendered on the same page?
You may want to look into this:
How to include a partial view inside a webform

ASP.NET Ajax Accordion Control not working properly with ScriptManager

I've been reading SO for a while now, but that's the first time I post a question (first time I don't find the answer of what I'm looking for)
Here is my setup:
Master page:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Master.master.cs" Inherits="VatechWebsite.Master" %>
<html>
<head>...</head>
<body>
<form>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
...
<asp:ContentPlaceHolder ID="content" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
Content page:
<%# Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="Brand.aspx.cs" Inherits="VatechWebsite.Brand1" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
<asp:Accordion ID="CategoriesAccordion" runat="server" HeaderCssClass="AccordionHeader">
<HeaderTemplate><%# DataBinder.Eval(Container.DataItem, "CategoryName") %></HeaderTemplate>
<ContentTemplate>
<div id="ProductList">Some text<br />supposed to be very large <br/></div>
</ContentTemplate>
</asp:Accordion>
<asp:Content/>
When I run this page, the accordion displays correctly, binds data correctly, and has the first pane expanded. The problem is, I cannot expand/collapse a pane. It seems that the javascript associated with this control is not running correctly. If I replace ScriptManager in the master page with a ToolkitScriptManager, the problem is solved; but I don't want to do that because I have other pages that need the ScriptManager.
I read that the ScriptManager should be adequate for running asp ajax controls, so why is it not working in this case?
If you're stuck with one ScriptManager for some pages, and ToolKitScriptManager for another, there are ways to use the same master page on all your pages, and use different ScriptManager on different pages.
This answer details a few approaches, one approach will disable Master.ShowScriptManager = false; on PageLoad.
Disable ScriptManager on certain pages
Another suggests having different ScriptManagers on for different ContentPlaceHolders, which also works.
Hope this helps!

AjaxFileUpload Doesn't Display Correctly or Function: Mysterious Black Button

I found AjaxFileUpload in the toolkit when searching for ways to upload multiple files.
I used NuGet to install.
Added <%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%> to the top of the page.
Ensured web.config has the reference:
<pages>
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
Where I presume the the upload button should be, I get a black box, when I run the page. The preview does show up correctly.
I did try it in a completely empty page (no master page or anything) and I get the same result.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="School_Scheduler_2.Associates.test" %>
<%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ajaxToolkit:AjaxFileUpload runAt="server" ID="multiUpload" />
</form>
</body>
</html>
Any suggestions?
Answer Since My Account Is Too Noob to the Post Answer Myself
This explains it: https://ajaxcontroltoolkit.codeplex.com/workitem/27493
Long story short: The Ajax Tool Kit does not like the vanilla ScriptManager. It insists on using their own ToolkitScriptManager.
This causes havoc with my MasterPages (I put the script manager on there to save me from adding it everywhere), but at least I know now and can start scheming possible solutions.
try this
<asp:ToolkitScriptManager ID="ScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div align="center">
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" AllowedFileTypes="jpg,jpeg,png,gif"
MaximumNumberOfFiles="10" OnUploadComplete="File_Upload"
Width="500px" />
Old question, but make sure to debug any javascript errors. Any errors will cause the described black button.
If you have any client side code that runs on OnClientUploadCompleteAll=, but fail to copy this code to a new page if you are copy/pasting the AjaxFileUpload control, you get a javascript error and it fails to render the control at this point, just leaving you with the black button.

'GridView1' is not declared. It may be inaccessible due to its protection level.

I have created an asp.net Web application using Vb.net and added a default.aspx page which client sent me. following is markup of page:
<%# Page Title="" Language="VB" MasterPageFile="~/Content/MasterPages/HaloBackOffice.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Gate_Jape_Verifications_PostGate_AuditDocument_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</asp:Content>
In code behind, I am writing this:
GridView1.DataSource = ds
GridView1.DataBind()
GridView1.DataMember = "DataTable"
but getting error:
'GridView1' is not declared. It may be inaccessible due to its protection level.
Is can be reason of Page directive has different inherits value or Page was part of asp.net Website and I created Web application ?
Please suggest.

ASP.NET Different Layouts within 1 Site

A client has an ASP.NET website with master pages and a layout directory.
What we need is 2 different layouts on the site. Can I easily have two layouts with different master pages on the same site?
What's the best way to do that?
See Setting an ASP.NET Master Page at runtime. You can set any page to use any masterpage programmatically at runtime.
Yes. Just create two different master pages and point the corresponding aspx pages to the desired masterpage.
Example:
page1.aspx
<% # Page Language="C#" MasterPageFile="~/Master.master" Title="Content Page 1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
Main content.
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Footer" Runat="Server" >
Footer content.
</asp:content>
page2.aspx
<% # Page Language="C#" MasterPageFile="~/secondary.master" Title="Content Page 2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
Main content.
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Footer" Runat="Server" >
Footer content.
</asp:content>

Resources