Archive

Archive for the ‘ASP .Net’ Category

CKEditor HTML view greyed out

November 3rd, 2013 No comments

The Problem

When running CKEditor (3.6.4 for ASP.NET) the editor loads but the HTML view is greyed out.
Switch to source mode and the HTML code is there but it does not render in HTML View

Diagnosis

On further investigation this error only appears to occur in Internet Explorer 10, (IE10) when the browser is running in quirks mode.

To reproduce open the following URL which takes you to a earlier demo of CKEditor 3.6.4

http://rev.ckeditor.com/ckeditor/trunk/7500/_samples/skins.html

In Internet Explorer do the following:

  1. Press F12 – to launch the developer Tools
  2. On the menubar – Look for Document Mode and change to Quirks mode

IEQuirksMode

When in quirks mode the control greys out. Switch back the Standard mode and it works.

The Solution

You can control which mode the browser runs in, by adjusting the

VN:F [1.9.22_1171]
Rating: 4.0/10 (1 vote cast)

Categories: ASP .Net Tags:

ApplicationPoolIdentity find the user account

May 22nd, 2012 No comments

The Problem

How do you find the ApplicationPoolIdentity Account?

Under IIS 7 you have the ability to set the user account that the Application Pool will run under. By Default this appears to be a setting called “ApplicationPoolIdentity”.

So if you need to provide access for this user to a local system resource how do you find the user account when you are searching in the security tab?

The Answer

When the application pool is created a new user account is created with the name of the Application Pool.
This account is created on the local machine in the format of:
IIS AppPool\AppPoolName – where AppPoolName is the name of your application pool

So for example the DefaultAppPool user can be found by searching for:
IIS AppPool\DefaultAppPool

Application Pool Identify - prior to resolve

When Resolved

Application Pool Identity Resolved

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: ASP .Net, OS Tags:

jQuery – enable / disable (readonly) and how to reference .Net Server side Controls

September 8th, 2010 No comments

Ok, I am just starting to play around with jQuery and these are a couple of tips that I have found useful.

1. How to access .net server side controls
The code to get the value from a html input control <input id=”name”> might be as follow:
var name = $(‘#name’).val();

For a server side control like <asp:TextBox ID=”txtName” runAt=”sever” /> you can reference it as follows:
var name = $(‘#<%=txtName.ClientID%>’).val();

I have a user control for date selection called the DateSelector, and it has a control inside it called txtDate which stores the selected date.
If I want to get the value from within a user control like this I can do:

var dte = $(‘#<%=dteDateSelector.ClientID%>_txtDate’).val();

2. Disable a control
In this case I want to disable a text box from the txtName example above:
$(‘#<%=txtName.ClientID%>’).attr(“disabled”, true);
to clear it
$(‘#<%=txtName.ClientID%>’).removeAttr(“disabled”)

A problem with disabling controls in this way is that their values cannot be read in javascript, so another way is to use the “ReadOnly” attribute
$(‘#<%=txtName.ClientID%>’).attr(“readonly”, true);
to clear it
$(‘#<%=txtName.ClientID%>’).removeAttr(“readonly”)

Cheers

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

Categories: ASP .Net, jQuery Tags:

ASP.Net Membership Provider – Install Database

August 30th, 2010 No comments

In asp.net the membership provider model is a cool way of easily getting a security datamodel with role access.

The database can be installed on your own specific database in the following way.

Some architecture based sugestions:
1. The membership provider model is actually keyed by application. So you can provide user lists for multiple applications from a single database. This means that instead of creating the model inside you application database you can store this in a central applicaiton security database and provide a single database that manages users for all of your applications.

Pre-Requisites
1. Ensure you have SQL server installed on your system. This could be SQL Server Express.

Installation
1. Open a command window.
2. cd to the following directory [drive:]%windir%Microsoft.NETFrameworkversion
3. run aspnet_regsql.exe ( by default this will run in the Wizard Mode)

In the wizard:
1. Click Next
2. Choose “Configure sql server for application services” and click next
3. Select the Server and Database set your database connection details (note change to sqlExpress named instance)
4. Choose Next Next Finish

Your database has now been created and is ready to be used.

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

Categories: ASP .Net Tags:

RequiredFieldValidator conditional validation via client side script

May 27th, 2010 No comments

Interesting Problem.

I created a user edit page on an ASP.Net website. A user when looking at their own record got a “Change Password” panel. It is optional and only updated if data is entered in the text boxes. I wanted to use the CompareValidator to compare the txtPassword and txtConfirmPassword textboxes.

This worked great, I set up the CompareValidator to validate the txtConfirmPassword against the txtPassword. Problem is the ConfirmValidator does not fire when there is nothing entered in the txtConfirmPassword textbox. So the user could enter a password and click submit and the compare validator would not fire and the page would submit.

So I needed a RequiredFieldValidator on txtConfirmPassword but this is only needed to be enabled after some text is entered in the txtPassword text box.

I found this article:
http://www.aspdotnetfaq.com/Faq/How-to-control-ASP-NET-Validator-Controls-Client-Side-validation-from-JavaScript.aspx

and implemented this javascript. Note I am using a little jQuery to get the controls. (1.4.1)

And using this information was able to write the following script:

<script type="text/javascript">
    $(document).ready(function() {
        $('#<%=txtPassword.ClientID %>').change(function() {
            var value = $('#<%=txtPassword.ClientID %>').val();
            if(value.length > 0){
                EnableValidators(true);
            } else {
                EnableValidators(false);
            }
        });
    });

    function EnableValidators(enable)
    {
        ValidatorEnable(document.getElementById('<%=rfvConfirmPassword.ClientID%>'), enable);
    }
</script>

The interesting thing is “ValidatorEnable” is a Asp.Net function that client-side enables and disables the validators.

Nice 🙂

VN:F [1.9.22_1171]
Rating: 9.0/10 (1 vote cast)

Categories: ASP .Net, c# Tags:

Textbox – supress previous entries – auto complete off

April 1st, 2010 No comments

Hi,

I am developing a website and noticed that all my text boxes were repeating the content that had been entered previously.

Found this blog here;
http://ryanfarley.com/blog/archive/2005/02/23/1739.aspx (I like ryans stuff).

In short you can turn this off via the autocomplete=”off” property.
This can be set in a number of ways:

  1. On the form, this disables it for all content on the form. This is really handy if you are using master pages as add it to your master page and job done, your entire site now stops prompting.
  2. On a control by control basis;
    <asp:TextBox ID="txtText" runat="server" autocomplete="off" >

Note: Visual studio will complain that it does not know this property but it works none the less so just ignore VS.

Cheers

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: ASP .Net Tags:

AJAX PopupControlExtender and Dynamic Controls

February 28th, 2008 3 comments

I was attempting to use the PopupControl Extender the other day, to create myself a web user control for colour selection.

Here is what I ended up creating..
Figure 1

The problem I had was that the colour palette panel is being created dynamically. In this example it is a 25×16 matrix made up of 375 dynamically created link buttons with their backcolour set to the colour from the palette. (Note: Used a link button due to postback.Asynch javascript errors that occur with PopupControl Extender in a modal dialog box as documented elsewhere on the web).

When a user clicked on one of the link buttons it performed a postback, problem was it was doing a full postback and closing the popup window.

Solution: When creating your controls dynamically to exist in your panel to be displayed by the popup extender you need to register them with the UpdatePanel triggers collection like so:

LinkButton btnColour = new LinkButton();
... setup you link button
btnColour.ID = colurHexCode; // colurHexCode string variable containing the current colour I am setting as the backgroud
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = btnColour.ID;
UpdatePanel1.Triggers.Add(trigger);

This forces the dynamic control to be included in the update panel and when clicked only performs a partial update panel postback.

Sweet

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: AJAX, ASP .Net Tags:

Setting the Default Button on Pressing Enter

February 27th, 2008 1 comment

Issue
On a page with a single text box and a button, place your cursor in the text box and press enter. The page will submit back to itself but not hit the click event behind your submit button as expected.

See here: http://aspnet.4guysfromrolla.com/articles/060805-1.aspx for a full discussion of the issue.

Solution
The fix for this simple problem is to add another text box like so:

<asp:textbox runat="server" style="visibility:hidden; display:none;>

This however only fixes the page posting to itself, we now need to get the page to fire the default button’s click event.My problem is further complicated by these facts:

1. The page is using a master page with the main content area containing the text box and a footer content area containing the button.

2. The button is not an  <asp:button…  but a custom button control that uses an asp:hyperlink control.

There is a DefaultButton property that can be set on the form. The caveat being when using master pages you must use the uniqueID of the control. So in my page onload event the following line of code needs to be added.

this.Page.Form.DefaultButton = btnOK.UniqueID;

This causes the btnOk “Click” event to be fired.

Yeah!

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: ASP .Net Tags: