Jun 27, 2012
Jun 25, 2012
Jun 8, 2012
Handle Error on Web.Config file.
I prefer to use a generic error page, and redirect from there :
<system.web>
<customErrors mode="On" defaultRedirect="Errors.aspx"/>
</system.web>
And, in errors.aspx :
errors.aspx
-----------------
<html>
<script language="VB" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim errMessage As String = ""
Dim appException As System.Exception = Server.GetLastError()
If (TypeOf (appException) Is HttpException) Then
Dim checkException As HttpException = CType(appException, HttpException)
Select Case checkException.GetHttpCode
Case 400
errMessage &= "Bad request. The file size is too large."
Case 401
errMessage &= "You are not authorized to view this page."
Case 403
errMessage &= "You are not allowed to view that page."
Case 404
errMessage &= "The page you have requested can't be found."
Case 408
errMessage &= "The request has timed out."
Case 500
errMessage &= "The server can't fulfill your request."
Case Else
errMessage &= "The server has experienced an error."
End Select
Else
errMessage &= "The following error occurred<BR>" & appException.ToString
End If
ErrorMessage.Text = errMessage & "<BR>We're sorry for the inconvenience."
Server.ClearError()
End Sub
</script>
<body>
<hr>
<asp:label id="ErrorMessage" font-size="12" font-bold="true" runat=server/>
<hr>
<p>Return to <a href=http://yourserver.com/>our entry page</a>
</body>
</html>
---------------
<system.web>
<customErrors mode="On" defaultRedirect="Errors.aspx"/>
</system.web>
And, in errors.aspx :
errors.aspx
-----------------
<html>
<script language="VB" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim errMessage As String = ""
Dim appException As System.Exception = Server.GetLastError()
If (TypeOf (appException) Is HttpException) Then
Dim checkException As HttpException = CType(appException, HttpException)
Select Case checkException.GetHttpCode
Case 400
errMessage &= "Bad request. The file size is too large."
Case 401
errMessage &= "You are not authorized to view this page."
Case 403
errMessage &= "You are not allowed to view that page."
Case 404
errMessage &= "The page you have requested can't be found."
Case 408
errMessage &= "The request has timed out."
Case 500
errMessage &= "The server can't fulfill your request."
Case Else
errMessage &= "The server has experienced an error."
End Select
Else
errMessage &= "The following error occurred<BR>" & appException.ToString
End If
ErrorMessage.Text = errMessage & "<BR>We're sorry for the inconvenience."
Server.ClearError()
End Sub
</script>
<body>
<hr>
<asp:label id="ErrorMessage" font-size="12" font-bold="true" runat=server/>
<hr>
<p>Return to <a href=http://yourserver.com/>our entry page</a>
</body>
</html>
---------------
May 11, 2012
how to Set Character Limit for TextArea and TextBox
This script allows you to set a limit on the number of characters a user can enter into a textarea or text field, like so:
Insert the following code into the page head:
<script language="javascript" type="text/javascript">
if (limitField.value.length > limitNum)
{
limitField.value = limitField.value.substring(0, limitNum);
limitCount.value = limitNum - limitField.value.length;
}
else
{
limitCount.value = limitNum - limitField.value.length;
}
}
</script>
Step 2 - For Text Area
Use the following code to create the form and text area (if necessary, change the name of the form and text area to suit your needs):
<form name="myform"> <textarea name="limitedtextarea" onKeyDown="limitText(this,countdown,100);" onKeyUp="limitText(this,countdown,100);"> </textarea><br> <font size="1">(Maximum characters: 100)<br> You have <input readonly type="text" name="countdown" size="3" value="100"> characters left.</font> </form>
Step 2 - For Text Box
<form name="myform"> <input name="limitedtextfield" type="text" onKeyDown="limitText(this,countdown,15);" onKeyUp="limitText(this.form.limitedtextfield,this.form.countdown,15);" maxlength="15"><br> <font size="1">(Maximum characters: 15)<br> You have <input readonly type="text" name="countdown" size="3" value="15"> characters left.</font> </form>
May 4, 2012
Simple Crystal reports In ASP.net
Dim ObjDb As New DBAccess
Dim objRptDoc As New ReportDocument
Dim myDiscreteValue As New ParameterDiscreteValue
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
FunGenerateReport()
End Sub
Protected Sub FunGenerateReport()
Dim strRptFile As String
strRptFile = Server.MapPath("rptFaapBudget.rpt")
objRptDoc.Load(strRptFile)
objRptDoc.SetDatabaseLogon("MyUserName", "PWD", "192.168.1.192", ObjDb.GetConnection().Database.ToString())
myDiscreteValue = New ParameterDiscreteValue
myDiscreteValue.Value = Convert.ToString(Request.QueryString("strYear"))
objRptDoc.ParameterFields("@finYear").CurrentValues.Add(myDiscreteValue)
myDiscreteValue = New ParameterDiscreteValue
myDiscreteValue.Value = Convert.ToString(Request.QueryString("strCompCode"))
objRptDoc.ParameterFields("@CompCode").CurrentValues.Add(myDiscreteValue)
CrystalReportViewer1.ReportSource = objRptDoc
CrystalReportViewer1.HasExportButton = True
'CrystalReportViewer1.HasToggleGroupTreeButton = False
End Sub
Apr 28, 2012
How to show fileupload on apple browser
Recently i was facing problem in fileupload on ipad or Apple OS , i searched a lot on the net., but did not get any solution. The only answer which i got was that Apple file System doesn't allow access to fileupload control.
So finally i checked my asp.net Web Application on apple's macbook and it's supports and allow to upload files.
During the search i found that may be usefull link for file upload on iPhone.
http://picupapp.com/scratchpad.html
http://asp.net.bigresource.com/Mobiles-upload-file-not-working-for-IPad-IPhone--mbuXPbNLH.html
----------------------------------------------------------------------------------
So finally i checked my asp.net Web Application on apple's macbook and it's supports and allow to upload files.
During the search i found that may be usefull link for file upload on iPhone.
http://picupapp.com/scratchpad.html
http://asp.net.bigresource.com/Mobiles-upload-file-not-working-for-IPad-IPhone--mbuXPbNLH.html
----------------------------------------------------------------------------------
Apr 17, 2012
Simply Hide and show in javascript
Use below images ..
====================== ASPX Script =======================
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<table style="width: 308px; background-color: cadetblue">
<tr>
<td style="height: 30px">
<img id="img1" src="Images/gvCollapsedButton.png" onClick="return Fun1();" />
<asp:Label ID="Button1" runat="server" Text="click on me to Expand / Collapse" OnClientClick="return Fun1();" /></td>
</tr>
<tr>
<td>
<div id ="MyDiv" style="background-color: #ccffff; width: 300px; height: 59px; display: none;">
<br />
UserName :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></div>
</td>
</tr>
</table>
</form>
</body>
<script type="text/javascript" language="javascript" >
// global variable
var status= "close";
// ============== Script to hide and show ....
function Fun1()
{
if (status=="close")
{
document.getElementById("MyDiv").style.display = 'block';
document.getElementById("img1").src= 'Images/gvExpandedButton.png';
status="open";
}
else
{
document.getElementById("MyDiv").style.display = 'none';
document.getElementById("img1").src= 'Images/gvCollapsedButton.png';
status="close";
}
return false;
}
//=====================
</script>
</html>
==============================================================
Subscribe to:
Posts (Atom)
-
Bootstrap css front-end framework. jQuery fast, small, and feature-rich JavaScript library. DataTables advanced interaction contro...
-
click on below link to send sms http://www.eggheadcafe.com/community/asp-net/17/10281633/code-to-send-sms-using-webservice-like-way2sms.as...
-
// use the following event in Your script tag function pageLoad(sender, args) { if (args.get_isPartialLoad()) { //alert(...
What is the use of n-tier architecture and 3-tier architecture?
how to implement 3-tier architecture in asp.net using c#. 3-Tier architecture is also called layered architecture. Some people called it ...



