problem with html editor - asp.net

I used Html Editor with firefox on my pc. I switched pcs and I tested my site again.. The HTML editor appears completely messed up across browsers ..It doesnt even look as good as it
is on the original pc i deployed it.
The question is why? And should I use ajax at all instead of jquery?
All the pages markup:
<%# Page Title="" Language="C#" MasterPageFile="~/YourGuruMaster.master" AutoEventWireup="true" CodeFile="PostEdit.aspx.cs" Inherits="PostEdit" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit.HTMLEditor" tagprefix="cc1" %>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder>
<cc1:Editor
ID="Editor1"
Width="850px"
Height="400px"
runat="server"/>
<br />
<asp:Button
id="btnSubmit"
Text="Submit"
Runat="server" onclick="btnSubmit_Click" />
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="Editor1" ErrorMessage="אין להשאיר שדות רקים"
ForeColor="#CC0000"></asp:RequiredFieldValidator>

1.) This is a much deeper problem. You probably need to add more rules to your css stylesheet. If you want the site to look the same across different browsers, you have to look into cross browser support and cross browser compatibility.
2.) The jQuery library has a full suite of AJAX capabilities. There is no need to use self-made js functions to create AJAX calls. Stick with jQuery.

Related

No event is firing in asp.net

In my website No button event is firing.
<asp:Button ID="Button1" Text="Add_Record" runat="server" AutoPostBack="true"
onclick="Button1_Click" />
when I write code in the event handler. It does not call.
On every page of website I am facing this issue.
<div id="eList">
<p>Enter Your Email To Sign Up<br>
For Our E-Newsletter:</p>
<asp:TextBox ID="elist_input" runat="server" Width="169px">
</asp:TextBox>
<br>
<asp:Button class="elist_submit" runat="server" Text="Search" Width="56px"
onclick="Unnamed1_Click" />
<div id="display_menu_2">
<asp:Button ID="Button1" Text="Add_Record" runat="server"
AutoPostBack="true" onclick="Button1_Click" />
Page Directive
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="HomePage.aspx.cs" Inherits="homePage" %>
Your project must have been Web application project and the CodeFile attribute is valid only in Web site project for compiled pages, change it to the CodeBehind like this.
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeBehind="HomePage.aspx.cs" Inherits="homePage" %>
I was not able to call the event handlers. the problem was due to the header.ascx file. In that file I used form and also a form in Master page. As Master page is inhereted to all pages and header is also. due to two form in one page event handlers were not working..

ToolkitScriptManager is not a known element

I have a website in which I am using the AJAX Accordion Pane. In order to fully use the RequireOpenedPane="False" I need to have the ToolkitScriptManager added to the site.
I understand all of this but there's an issue. Visual Studio 2012 says the ToolkitScriptManager is not a known element
I have
<add tagPrefix="asp" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
in the web.config file, and
<asp:Accordion ID="Accordion1" runat="server" CssClass="accordion" SelectedIndex="-1" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" RequireOpenedPane="False" FramesPerSecond="25" Width="820px" >
works with no errors. But
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
does not.
Here's the funny thing, if I remove the ToolkitScriptManager from the page, it'll load the Accordion, however, not all functionality will be working (for example, clicking an accordion header does not select the header, it just expands the header, but does not show as "Selected").
The page DOES have a MasterPage as well, the ToolkitScriptManager is inside the ContentPlaceHolder for the body. (it's actually right above the Accordion control). Why is this doing this, and how can I fix it?
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="page.aspx.cs" Inherits="page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MenuContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<h1 align="center">Classes</h1>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
<asp:Accordion ID="Accordion1" runat="server" CssClass="accordion" SelectedIndex="-1" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" RequireOpenedPane="False" FramesPerSecond="25" Width="820px" >
<Panes>
<asp:AccordionPane runat="server" ID="AccordionPane0">`
Found solution:
Apparently the AjaxControlToolkit obtained from using the NuGet installer on Visual Studio 2010 does NOT have the ToolkitScriptManager. I had to remove the DLL installed from NuGet and install my own DLL which did include the ToolkitScriptManager.
I'm not sure why the NuGet version does not contain the ToolkitScriptManager.
On top of your solution user1760784, others may ALSO need to setup IIS first and import their app in. Once the app is fully setup in IIS then try to run it. It should work. With this process done my issue was resolved.
Please note this is true for both test IIS and live/production IIS. Although as we all know it's always safer to test off live boxes.
Why does it only resolve when testing on IIS?
I don't really know. However I believe it could because of http/browser issues. Maybe you smarter folks can let us know on this point.
Enjoy!

Prevent Visual Studio from adding child controls

I have a bit of a strange issue here. I created a custom control as such:
public class Textbox : System.Web.WebControls.Placeholder
{
if( [certain criteria are met])
this.Controls.Add(new System.Web.WebControls.Textbox());
}
When working in Visual Studio's designer mode, anytime I add one of my textboxes to the page:
<myControls:Textbox id="txtTest" runat="server" />
Visual studio has a habit of changing my markup to the following:
<myControls:Textbox id="txtTest" runat="server" >
<asp:Textbox runat="server" />
</myControls:Textbox>
This changes the final output markup so that two textboxes appear. Is there a way to prevent visual studio from doing this?
EDIT:
As per request, here is the page markup
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="TestApp.Test" %>
<%# Register Assembly="MyControls.WebControls" Namespace="MyControls.WebControls" TagPrefix="myControls" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<table>
<tr>
<td>
<asp:Label ID="lblTest" runat="server">Test Label:</asp:Label>
<myControls:TextBox ID="txtTest" runat="server" Width="80px"></myControls:TextBox>
</td>
</tr>
</table>
</asp:Content>
I think that's happening because your class inherits from the PlaceHolder control, which implements the TemplateControl class. I don't know if there was a reason for this, but it seems like it would be more approriate if you inherited from the TextBox control instead.
EDIT
Since you're using logic to render one of several controls, I would inherit from the WebControl class instead. This will allow you render basically anything you want. Although I must admit, what you're trying to do is probably going to require a substantial amount of work.
If I understand the issue correctly, you are having problems at design time and not runtime.
If this is the case, you should wrap your control add code with a test that ensures it is only executed when you are not in design mode. For example:
if ((!this.InDesignMode) && ( [certain criteria are met]))
this.Controls.Add(new System.Web.WebControls.Textbox());

Ajax change language

I saw in a lot of AjaxControlToolkit.resources.dll for different languages, even mine (Russian) in my bin folder so I guess that's real to change the language of my Ajax Calendar Extender.
<asp:TextBox ID="TextBox4" runat="server" oninit="TextBox4_Init" />
<ajaxToolkit:CalendarExtender ID="TextBox4_CalendarExtender" runat="server"
Enabled="True" FirstDayOfWeek="Monday" Format="dd.MM.yyyy"
TargetControlID="TextBox4" />
<br />
It's English by default
But how can I change it to my Language ? (or to the current culture language)
I've tried
<%# Page Title="gfregrhtrhr" Language="Nemerle" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
CodeBehind="Report.aspx.n" Inherits="Flow_WEB_Nemerle.Report" Culture="ru-RU" UICulture="ru-RU" %>
but it made no sense for calendar :-/
by the way I have some fun in comparing my page and
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Calendar/Calendar.aspx
there I can see month names etc on Russian BUT "Today" an english >_< instead on my page month names are English and "Today" is Russian "Сегодня" ... is it phenomenon
Finally fixed by adding
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnableScriptGlobalization="true" EnableScriptLocalization="true"/>
The components are going to work by default in the language defined in the page culture property in your page directive. This directive also fix the date format and all the culture relative parameters and preferences.
This is an example to set them work for English-United Kingdom:
<%# Page Language="C#" Culture="en-UK" UICulture="en-UK" %>
You must set EnableScriptGlobalization="true" in ToolkitScriptManager like this
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableScriptGlobalization="True"></asp:ToolkitScriptManager>

ASP.NET Controls are not coming in Code-behind IntelliSense

I am having an aspx page where I have added one asp.net text box control with ID and RUNAT attribute. But in Code-behind I am not seeing this control's name in the intellisense.
My page directive in aspx is as follows
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyProject_UI._Default" %>
I am using VS 2008. Any idea how to get rid of this?
Try using CodeFile instead of CodeBehind. The latter is a hold-over from .NET 1.1.
Also, make sure the namespaces match up between the markup and the code. Do a test compile to be sure.
I have seen this on occasion when I edit a page. When it happens to me, I close the files and open them again and it seems to fix itself.
This will happen if you are trying to include your control in LayoutTemplate. For example if you are using an asp label in a login control you have converted to a LayoutTemplate.
<asp:Login ID="userLogin" runat="server">
<LayoutTemplate>
<!--Username and password controls-->
<asp:Button ID="btnLogin" CommandName="Login" runat="server" Text="Login" />
<asp:Label ID="lblAlert" runat="server"></asp:Label>
</LayoutTemplate>
So your lblAlert will not show up on the code behind take it out of the layouttemplate or use a loop to find the control within the layout object.
var mylabel = (Label)userLogin.FindControl("lblAlert");

Resources