Monday, August 20, 2012

Debugging is not supported under current trust level settings?

Today When I was debugging a test website I created for learning I got the error “Debugging is not supported under current trust level settings?

This error normally occurs when you keep the website directly under C:\inetpub\wwwroot folder. Anyway that is not a subject here. We will directly go to the simple solution to resolve the issue.

Open your Web.config and add below line in

<system.web>
    <trust level="Full"/> 
    .....
    .....
</system.web>

Tuesday, August 7, 2012

Window.Confirm in JavaScript.

 

Most of the time during web application development you may get a requirement to redirect the page based on user choice.

Here I am going to show you how to redirect to an another web page or site on click of a JavaScript Ok button.

If you use Window.Confirm in JavaScript you will get OK and Cancel button. So we will redirect to another page only if user click on OK button. If user Click on Cancel button then we will stay on the same page.

So test the code first we will create a simple button

Below is the .ASPX code for creating a button.

<body>
<form id="form1" runat="server">
<div>

</div>
<asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click"
Text="Submit" />
</form>
</body>

Now in Code behind we will write the JavaScript code to redirect to another website.

protected void btnSubmit_Click(object sender, EventArgs e)
{

ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:if (window.confirm('You will be redirected to Dotnet Galaxy. Click OK to confirm')) { location.href = 'http://asheej.blogspot.in/'; }", true);

}

Now we will see how the alert will be
Cinfrim box in JavaScript