Tuesday, December 27, 2011

Selecting dropdown value using javascript

81 down vote accepted
If you have a select element that looks like this:
<select id="ddlViewBy">
<option value="1">test1</option>
<option value="2" selected="selected">test2</option>
<option value="3">test3</option>
</select>
Running this code:
var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].value;
Would make strUser be 2. If what you actually want is test2, then do this:
var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].text;

Sunday, December 18, 2011

Searching String or text from "stored procedure" defination

SELECT DISTINCT o.name ,o.xtype
FROM syscomments c
INNER JOIN sysobjects o ON c.id=o.id
WHERE c.TEXT LIKE '%Employee%'
GO

Tuesday, December 13, 2011

Set new value of radiobutton using javascript

 Use this script to set new value of radiobutton using javascript...

function buttonOnClick()
{
 var elementRef = document.getElementById('<%= RadioButton1.ClientID %>');
 var labelArray = elementRef.parentNode.getElementsByTagName('label');

 if ( labelArray.length > 0 )
  labelArray[0].innerHTML = 'Changed label';
}

Wednesday, December 7, 2011

Solution for The log file for database 'Database_Name' is full.

Error : "The log file for database 'Database_Name' is full."
After facing this problem , i want to share solution with all of you .

Use these following steps ,
this will shrink database log files and removes this ERROR
Queries  :-

USE Database_Name
GO
SELECT * FROM sysfiles WHERE name LIKE '%LOG%'
GO
USE [Database_Name]
GO
ALTER DATABASE [Database_Name] SET RECOVERY SIMPLE
GO
USE [Database_Name]
GO
CHECKPOINT
GO
USE [Database_Name]
GO
BACKUP LOG [Database_Name] WITH NO_LOG
GO
USE [Database_Name]
GO
SELECT Name FROM sysfiles WHERE name LIKE '%LOG%'
GO
USE [Database_Name]
GO
DBCC SHRINKFILE ([Database_Name_log], 1)
GO
USE [Database_Name]
GO
SELECT * FROM sysfiles WHERE name LIKE '%LOG%'
GO
USE [Database_Name]
GO
ALTER DATABASE [Database_Name] SET RECOVERY Full
GO

Just replace your database name with "Database_Name".
Thanks
Cheers

Monday, October 24, 2011

Beautiful introduction for HTML5

A very beautiful introduction on HTML5 new input tags

http://www.bipinjoshi.net/articles/e421a206-cb68-428b-939b-9e42a2feeec3.aspx

Friday, October 21, 2011

Send email using asp

Create an aspx page and Paste this code on the page and change the required credential on the page..


<%@ Language=VBScript %>
<% Option Explicit %>

<%

Dim strFrom
Dim strPassword
Dim strTo
Dim strSubject
Dim strRedirect
Dim strBody
Dim Field
Dim strSubmit
Dim strServer
Dim strThankyou

'=======================================
'---------------------------------------
'        Inside HTML File IMPUT
'---------------------------------------
'<form name = "mail" action="mail.asp" method="POST">
'---------------------------------------
'=======================================
'---------------------------------------
'        Information to Edit
'---------------------------------------
strFrom = "email@domain.com"
strTo = "email@domain.com"
'strTo = "email@domain.com"
strServer = "mail.domain.com"
strThankyou = "thankyou.htm"
'---------------------------------------
' POP/SMTP Password
'---------------------------------------
strPassword = "******"
'=======================================

'strSubject = Request("Subject")
'strSubject = Request("Title of the Paper Presentation")
strRedirect = Request("Redirect")

If Request.QueryString <> "" Then

    'For Each Field in Request.QueryString
        If LCase(Field) <> "Email" And LCase(Field) <> "to" And _
        LCase(Field)<> "subject" And LCase(Field) <> "redirect" And _
        Lcase(Field)<> "submit" Then
            'strBody = strBody & Field & ": " & Request(Field) & chr(13)+ chr(10)
            strbody=strbody&"Name                            :"&Trim(Request("firstname"))&"  "&chr(13)+chr(10)
            strbody=strbody&"Address                    :"&Trim(Request("address"))&"  "&chr(13)+chr(10)
            strbody=strbody&"E-mail                           :"&Trim(Request("email"))&"  "&chr(13)+chr(10)
            strbody=strbody&"Mobile No           :"&Trim(Request("phone"))&"  "&chr(13)+chr(10)
            strbody=strbody&"Zip / Pin code :"&Trim(Request("zip"))&"  "&chr(13)+chr(10)
            strbody=strbody&"Feedback             :"&Trim(Request("feedback"))&"  "&chr(13)+chr(10)
           
        End If
    'Next
   
Else
   

    'For Each Field in Request.Form
       
        If LCase(Field) <> "Email" And LCase(Field) <> "to" And _
        LCase(Field)<> "subject" And LCase(Field) <> "redirect" And _
        Lcase(Field)<> "submit" Then
            'strBody = strBody & Field & ": " & Request(Field) & chr(13)+ chr(10)
            strbody=strbody&"Name                            :"&Trim(Request("firstname"))&"  "&chr(13)+chr(10)
            strbody=strbody&"Address                    :"&Trim(Request("address"))&"  "&chr(13)+chr(10)
            strbody=strbody&"E-mail                           :"&Trim(Request("email"))&"  "&chr(13)+chr(10)
            strbody=strbody&"Mobile No           :"&Trim(Request("phone"))&"  "&chr(13)+chr(10)
            strbody=strbody&"Zip / Pin code  :"&Trim(Request("zip"))&"  "&chr(13)+chr(10)
            strbody=strbody&"Feedback             :"&Trim(Request("feedback"))&"  "&chr(13)+chr(10)
           
           
        End If
       
    'Next


End If

SendMail strFrom,strTo,strSubject,strBody,strServer,strThankyou,strPassword

%>


<%

Sub SendMail(strFrom,strTo,strSubject,strBody,strServer,strThankyou,strPassword)

On Error Resume Next

Dim Mailer
Set Mailer = server.createobject("CDO.Message")

Mailer.From = strFrom
Mailer.To = strTo
Mailer.TextBody = strBody
Mailer.Subject = "Contact Information"
'Mailer.Subject = request("sub")
With Mailer.Configuration
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strServer
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'------------------------------------------------------------------------------
' For SMTP Authentication Modify ('.Fields) to (.Fields) for three fields Below
'------------------------------------------------------------------------------
'.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = strFrom
'.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strPassword
'------------------------------------------------------------------------------
.Fields.Update
End With

Mailer.Send
Set Mailer = Nothing

If Err.number<>0 Then
    Response.Write Err.Description
    Response.End
End If

Response.Redirect str Thankyou

End Sub

%>