Saturday, May 25, 2019

Angular 7 CRUD with Asp.Net Core With Web API using EF

CRUD Operations - Insert, update, delete and retrieve are implemented in Asp.Net Core Web API with Angular 7. First of all we'll build a Web API project in Asp.Net Core with required methods at server side using Entity Framework Core and SQL Server DB. download https://goo.gl/3SvTLK Refrence from CodAffection. All credit goes to CodAffection . for MVC with Web API https://goo.gl/pj9Equ taken referenve from CodAffection

Thursday, June 25, 2015

Function RandomNumberForLogo1(intHighNumber,intLowNumber)
intHighNumber = intHighNumber
intLowNumber = intLowNumber
dim arrOfRandNo(4)
For i = 0 to 3
Randomize
intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)
MyRandomNo = intNumber
For y = 0 To 3

If intNumber = arrOfRandNo(y) Then
intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)
MyRandomNo = intNumber
End If
Next
arrOfRandNo(i) = intNumber
Next
RandomNumberForLogo1 = arrOfRandNo
End Function

Tuesday, January 6, 2015

Pagination in ASP | Using ASP Classic | ASP VB script

Pagination in ASP | Using ASP Classic | ASP VB script

<% 'declare var
Dim Currpage, pageLen, lastNumber, PageRem, PageTen
Dim connection, recordset, STRSql, sConnString, next10, prev10, P
Dim RSPrevPage, RSNextPage, start
'Get the current page the user is on, if it's the first time they
'visit and the variable 'PageNo' is empty, then 'CurrPage' gets set to 1
'Else the current page variable 'CurrPage' is set to the page number requested
If IsEmpty(Request.Querystring("PageNo")) then
CurrPage = 1
Else
CurrPage = Cint(Request.Querystring("PageNo"))
End If
'the two functions below return the next 10 and prev 10 page number
Function getNext10(num)
pageLen = len(num)
If pageLen = 1 Then
next10 = 10
Else If pageLen>1 Then
pageRem = 10
pageTen = right(num, 1)
next10 = num + pageRem - pageTen
End If
End If
getNext10 = next10
End Function
Function getPrev10(num)
pageLen = len(num)
If pageLen = 1 then
prev10 = 1
Else If pageLen>1 then
lastNumber = right(num, 1)
prev10 = num - lastNumber - 10
End If
If prev10 = 0 then
prev10 = 1
End If
End If
getPrev10 = prev10
End Function
'create an instance of the ADO connection and recordset object
Set Recordset = Server.CreateObject("ADODB.Recordset")
'define the connection string
sConnString = Application("DSN")
'define our SQL variable
STRSql="SELECT * FROM tablename"
'Next set the location of the recordset
Recordset.CursorLocation = 3
'Execute the SQL and return our recordset
Recordset.open STRSql, sConnString
' pagesize is used to set the number of records that will be
' displayed on each page. For our purposes 10 records is what we want.
Recordset.PageSize = 10
'get the next 10 and prev 10 page number
next10 = getNext10(CurrPage)
prev10 = getPrev10(CurrPage)
'If there are no records
If Recordset.EOF Then
Response.write "No records to display"
Else
'this moves the record pointer to the first record of the current page
Recordset.AbsolutePage = CurrPage
'the below loop will loop until all the records of the current page have been
'displayed or it has reached the end of the recordset
Do Until Recordset.AbsolutePage <> CurrPage OR Recordset.Eof
'you can change these according to your database and table fields
response.write "ID: " & Recordset ("ID") & "
"
response.write "name: " & Recordset ("name") & "
"
response.write "Address: " & Recordset ("address") & "

"
Recordset.MoveNext
Loop
End If
'the next 2 lines setup the page number for the "previous" and "next" links
RSPrevPage = CurrPage -1
RSNextPage = CurrPage + 1
'find out the number of pages returned in the recordset
'if the Next10 page number is greater than the recordset page count
'then set Next10 to the recordset pagecount
If Next10 > Recordset.PageCount Then
Next10 = Recordset.PageCount
End If
'the variable start determines where to start the page number navigation
' i.e. 1, 10, 20, 30 and so on.
If prev10 = 1 AND next10 - 1 < 10 Then
start = 1
Else
start = Next10 - 10
If right(start, 1) > 0 Then
start = replace(start, right(start, 1), "0")
start = start + 10
End If
End If
'This checks to make sure that there is more than one page of results
If Recordset.PageCount > 1 Then
'Work out whether to show the Previous 10 '<<'
If currpage > 1 Then
response.write("<< ")
End If
'Work out whether to show the Previous link '<'
If NOT RSPrevPage = 0 then
response.write("< ")
End If
'Loop through the page number navigation using P as our loopcounter variable
For P = start to Next10
If NOT P = CurrPage then
response.write("" & P & " ")
Else
'Don't hyperlink the current page number
response.write(" " & P & " ")
End If
Next
'this does the same as the "previous" link, but for the "next" link
If NOT RSNextPage > Recordset.PageCount Then
response.write("> ")
End If
'Work out whether to show the Next 10 '>>'
If NOT Next10 = Recordset.PageCount Then
response.write(" >>")
End If
End If
%>

Monday, December 1, 2014

Calculate age Using Sql server script Calculate age Using Sql server script 2008, 2005

Calculate age Using Sql server

create function CalcAge (@dob datetime)
returns varchar(64)
as
begin
declare @age int
declare @getdate datetime = getdate()
if @dob >= @getdate
return 'Invalid input Parameter'
set @age = datediff(yy, @dob, @getdate)
if month(@dob) > month(@getdate) or
(month(@dob) = month(@getdate) and
day(@dob) > day(@getdate))
set @age = @age - 1
return convert(varchar,@age) + ' Years and ' + convert(varchar,datediff(dd,dateadd(yy,@age,@dob),@getdate)) + ' Days'
end

Tuesday, November 25, 2014

Enabling Unobtrusive Validation Mode in ASP.NET

Microsoft Visual Studio 2013 provides new Validation features which is include Unobtrusive Validation. Whenever you need to work with such type of Validation mode you will have to firstly configure your Web Application.

How to configure your Web.Config File

< configuration >
< appSettings >
< add key="ValidationSettings:UnobtrusiveValidationMode" value="None" >
< /appSettings >
< system.web >
< compilation debug="true" targetFramework="4.5" />
< httpRuntime targetFramework="4.5" />
< /system.web >
< /configuration >



How to configure your .aspx File

< asp:TextBox runat="server" ID="txt" />
< asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="txt is required" ControlToValidate="txt" runat="server" Text="Text is Required" Display="Dynamic" />
< asp:Button ID="Button1" Text="Submit" runat="server" />

Thursday, October 30, 2014

how to read all filename from folder using ASP Vbscript

Read all filenames from folder using ASP Classic Vbscript

Sometimes you require to get a list of all the files name from a folder, I was thinking how it can be implemented, the solution is to used the interface and write a script in VBScript. There is a sample script which is build in ASP Vbscript will get the list of files on a Folder.

function GetFiles(pFolder, pPattern)
dim Filelist
set Filelist = Server.CreateObject("SCRIPTING.DICTIONARY")
dim Regex
set Regex = new RegExp
Regex.IgnoreCase = true
Regex.Pattern = pPattern
dim Fso
set Fso = Server.CreateObject("SCRIPTING.FILESYSTEMOBJECT")
dim Folder
set Folder = Fso.GetFolder(Server.MapPath(pFolder))
dim File
for each File in Folder.Files
if Regex.Test(File.Name) then
Filelist.add File.Name, Array(File.Type, File.Size, File.DateLastModified)
end if
next
set File = nothing
set Folder = nothing
set Fso = nothing
set Regex = nothing
set GetFiles = Filelist
end function
dim Files
set Files = GetFiles("agencies", "\.(asp|gif|jpg|jpeg|png|tif)$")
if Files.Count = 0 then
Response.write "There are no images to display. "
end if
dim Filename
for each Filename in Files
Response.write Filename
Response.write Files(Filename)(0)
Response.write Files(Filename)(1)
Response.writeFiles(Filename)(2)
next
How To Generate Random String Using ASP Classic vb script, Sql

Generate Random String Using ASP Classic VB script, Sql

Simple and highly customizable function so that you can generate random strings using VBScript that you can use in your ASP/VBScript applications. The random strings can be used for various purposes: Referral Codes, Promotional Codes, Random password for new registrations

function GetRefID(Val)
tot_unique=8
rid = ""
redim random_letter(tot_unique)
randomize
For counter = 1 to tot_unique
random_number = Int(26 * Rnd + 97)
random_letter(counter) = Chr(random_number)
'response.write random_letter(counter)
for check=1 to counter-1
if random_letter(check)= random_letter(counter) then
counter=counter-1
end if
next
next
For counter = 1 to tot_unique
'response.write "
  • " & random_letter(counter) & "
  • "
    rid=rid & random_letter(counter)
    next
    Userid= Val & rid
    Sql="Select id from tbl Where id ='"&Userid&"' "
    Set Rs = objcon.execute(Sql)
    IF Not Rs.eof then
    GetRefID()
    Else
    GetRefID= Userid
    End IF
    Rs.close()
    Set Rs = Nothing
    End Function

    Tuesday, June 24, 2014

    Export Data in Excel with VBScript Classic ASP

    As i found lot of articles on the Internet, how to export a page to Excel using VBScript Classic ASP. There are very simple way to Create excel page using vbscript with the help of given steps.

    Step 1. 
    <%
    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader "Content-Disposition", "attachment; filename=My_List.xls"
    %>

    Step 2. 
    <html xmlns:x="urn:schemas-microsoft-com:office:excel">


    Sunday, December 8, 2013

    On Error Statement | Classic ASP | ASP | VB Script

    On Error Statement in VB Script

    Hello friends, let us start to learn about "On Error Resume Next", as we know run-time errors, stopped code and display error message. Some times we need to handle such type of Errors, in some cases.

    "On Error Resume Next" Statement provides the execution to continue with the statement immediately following the statement that caused the run-time error. In other words we can say "On Error Resume Next" statement is error-handling routine inline within the procedure.

    On Error Resume Next
    Err.Raise 6 ' Raise an overflow error.
    MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description
    Err.Clear ' Clear the error.

    Tuesday, November 5, 2013

    Dynamic Splash Page Using HTML CSS & Javascript with source Code

    Dynamic Splash Page Using HTML CSS & Javascript with source Code

    Hello Friends, lets us learn splash screen effects using Html, CSS & javascript. Now days we saw all major web sites like news sites, astrology sites, conference... etc uses of One time open pop-up (a small window) open. Now we are going to create so lets us start first Css page then Html page Then Javascript.

    There are some segments of One time open pop-up page, collcet it in one page and run your browser.

    Css Part:
    #popup0 {
    visibility: hidden;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    text-align: center;
    z-index: 200;
    }

    #popup0 .box-area {
    width: 700px;
    margin: 100px auto;
    background-color: #c04204;
    background: -webkit-gradient(radial, center center, 0, center center, 460, from(#fd3803), to(#c04204));
    background: -webkit-radial-gradient(circle, #fd3803, #c04204);
    background: -moz-radial-gradient(circle, #fd3803, #c04204);
    background: -ms-radial-gradient(circle, #fd3803, #c04204);
    border: 5px solid #fff;
    text-align: center;
    -moz-box-shadow: inset 0 0 15px 10px #802c03;
    -webkit-box-shadow: inset 0 0 15px 10px #802c03;
    box-shadow: inset 0 0 15px 10px #802c03;
    border-radius: 5px;
    }

    .close {
    margin: -20px 0px 0 690px;
    position: absolute;
    display: block;
    width: 30px;
    height: 30px;
    box-shadow: 0 0 0px #666;
    border-radius: 100%;
    background:url(close-button.png)no-repeat;
    }

    #popup0 h2 {
    display: block;
    padding-left: 15px;
    margin: 0px auto 10px;
    font-size: 36px;
    color: #fff;
    text-align:left;
    }

    #popup0 h3 {
    display: block;
    padding-left: 15px;
    margin: 0px auto 10px;
    font-size: 18px;
    color: #fff;
    text-align:left;
    }

    .header-area {
    border-bottom: 0px solid #ddd;
    padding: 10px 0 0;
    }

    .footer-area {
    border-top: 0px solid #ddd;
    padding: 10px 0;
    }

    .col2 {
    float: right;
    width: 100%;
    height: 400px;
    }

    #overlay0 {
    visibility: hidden;
    position: fixed;
    left: 0px;
    top: 0px;
    width: 100%;
    height: 100%;
    background: #000;
    filter: alpha(Opacity = 70);
    opacity: 0.7;
    -moz-opacity: 0.7;
    -khtml-opacity: 0.7;
    z-index: 1;
    }

    HTML Part:
    < div id="overlay0">< /div>
    < div id="popup0">
    < div class="box-area">
    Your All pop-up page informetion will be here.
    < div style="clear: both">
    < /div>
    < /div>
    < /div>


    Javsscript Part:
    var interval = 20 * 20;
    function MyTimer() {
    //alert("Deepak Madheshiya");
    var timeOutValue = setTimeout(function () {
    showPopup('');
    }, interval);
    return timeOutValue;
    }

    function createCookie(name, value, days) {
    if (days) {
    var date = new Date();
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    var expires = "; expires=" + date.toGMTString();
    }

    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
    }

    function readCookie(name) {
    return null;
    }

    function setUrlCookies() {
    MyTimer();
    }

    var ADV_CODE = "01";
    var advcode;
    var cookiesname = ["ishowadv0"];
    var cookiesvalues = new Array();
    var overlayid = ["overlay0"];
    var popupid = ["popup0"];
    function showPopup() {
    var datetime = new Date();
    for (var i = 0; i < cookiesname.length; i++) {
    cookiesvalues[i] = readCookie(cookiesname[i]);
    if (cookiesvalues[i] == "" || cookiesvalues[i] == null) {
    advcode = cookiesname[i];
    ovr = document.getElementById(overlayid[i]);
    pop = document.getElementById(popupid[i]);
    ovr.style.visibility = (ovr.style.visibility == "visible") ? "hidden" : "visible";
    pop.style.visibility = (pop.style.visibility == "visible") ? "hidden" : "visible";
    createCookie("lastadvshowonday", datetime.getDate(), 1);
    break;
    }
    }
    }
    function closePopup(tag, tagvalue, overlayidpass, popupidpass) {
    document.getElementById(overlayidpass).style.visibility = 'hidden';
    document.getElementById(popupidpass).style.visibility = 'hidden';
    CreateClickSession(tag, tagvalue);
    }
    function CreateClickSession(tagname, tagvalue) {
    createCookie(advcode, "false", 1);
    }

    Sending email using CDOSYS in Classi ASP | The transport failed to connect to the server."

    CDO.Message - "The transport failed to connect to the server." | CDO.Message.1 error '80040213' | ASP Sending e-mail with CDOSYS

    Hello friends, today we learn new thing which is related to mail sending object in Classic ASP. In Classic ASP there are a CDOSYS, built-in component in Classis ASP. This component is used to send e-mails with ASP.

    How to create CDOSYS object?
    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Sending email with CDO"
    myMail.From="mymail@mydomain.com"
    myMail.To="someone@somedomain.com"
    myMail.TextBody="This is a message."
    myMail.Send
    set myMail=nothing
    %>

    How to Send a text e-mail with Bcc and CC fields:
    Simply Add following code in Above code myMail.Bcc="someoneelse@somedomain.com" myMail.Cc="someoneelse2@somedomain.com"

    Some misc code:
    Sending an HTML e-mail that sends a webpage from a website:
    myMail.CreateMHTMLBody "http://www.w3schools.com/asp/"
    Sending an HTML e-mail that sends a webpage from a file on your computer:
    myMail.CreateMHTMLBody "http://www.url.com/test.asp/"

    Sending a text e-mail with an Attachment:
    myMail.AddAttachment "c:\mydocuments\test.txt"

    Sending a text e-mail using a remote server:
    <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.TextBody="This is a message." myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 'Name or IP of remote SMTP server myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com" 'Server port myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 myMail.Configuration.Fields.Update myMail.Send set myMail=nothing %>

    CDO.Message.1 The transport failed to connect to the server ?

    If you got such type of error check out following points:
    This is a network related error. Application cannot connect to the mail server (cdoSMTPServer)

    • Is a valid SMTP Server?
    • Be sure the server System.Web.Mail is executing on can connect to the mail server. May be firewalls or proxy servers can get in the way.
    • Specifying the value via IP address. Poor DNS resolution can sometimes hinder name lookups.
    • Make sure the that the mail server is running at port 25.
    • If you did not specify a SmtpMail.SmtpServer property, or if SmtpMail.SmtpServer points to "localhost" (or the equivalent), be sure the SMTP Service is running on port 25.
    • For testing purposes change the MailMessage.From and MailMessage.To properties to an address that exists on SmtpMail.SmtpServer. Some times this exception is thrown, when it really is a relay issue.

    Thursday, October 24, 2013

    Web Storage Demo With Example using HTML 5

    Web Storage Demo With Example using HTML 5
    Hello friends, Today we will start to learn new topic using Web Storage Using HTML 5 with Example. So that you can learn step by step. Now Let us start to play web Storage in Html 5.
    We are assuming that you know HTTP session cookies. There are two mechanisms by HTML 5, similar to HTTP session cookies. But there are some Draw Backs.
    First is that Cookies are include with HTTP request so there are problems to slow down your web sites by transmitting the same data.
    Second is that sending data not encrypted over the internet and also Cookies are limited data transmission 4 kb. There are mot enough to store required data.
    So, HTML 5 provides to handle Such type of situations using session storage and local storage.
    What is Session Storage?
    It is designed for scenarios where the user is carrying out a single transaction. but user can be carrying out multiple transactions in different windows at the same time.

    For Example: Use Given Code in body section.
    Hello friends, Today we will start to learn new topic using Web Storage Using HTML 5 with Example. So that you can learn step by step. Now Let us start to play web Storage in Html 5.
    We are assuming that you know HTTP session cookies. There are two mechanisms by HTML 5, similar to HTTP session cookies. But there are some DrawBacks.
    First is that Cookies are realated to HTTP request so there are problems to slow down your web sites by transmitting the same data.
    Second is that sending data unencrypted over the internet and also Cookies are limited data transmission 4 kb. There are mot enough to store required data.
    So, HTML 5 provides to handle Such type of situations using session storage and local storage.
    What is Session Storage?
    It is designed for scenarios where the user is carrying out a single transaction. but user can be carrying out multiple transactions in different windows at the same time.
    For Example: Use Given Code in script section.

    < script type="text/javascript"> if( sessionStorage.hits ){ sessionStorage.hits = Number(sessionStorage.hits) +1; }else{ sessionStorage.hits = 1; } document.write("Total Hits :" + sessionStorage.hits );


     
    Refresh the page to increase number of hits. Close the window and open it again and check the result. Refresh the page to increase number of hits. Close the window and open it again and check the result. What is Local Storage? It is designed for storage that spans multiple windows, and lasts beyond the current session. For Example: < script type="text/javascript"> if( localStorage.hits ){ localStorage.hits = Number(localStorage.hits) +1; }else{ localStorage.hits = 1; } document.write("Total Hits :" + localStorage.hits ); < /script>

    Refresh page to increase no of hits.

    Close the window and open it again and check the result and see magic.

    Saturday, July 20, 2013

    How to get detailed info about all online visitors that are currently browsing Using Classic ASP

    Count the number of current users / sessions using Classic asp VB script

    Count the number of current users / sessions:

    <%
     sub session_onStart()  
        application.lock() 
        application("SessionCount") = application("SessionCount") + 1 
        application.unlock() 
     end sub 
    sub session_onEnd()  
        application.lock() 
        application("SessionCount") = application("SessionCount") - 1 
        application.unlock()  
    end sub 
    sub application_onStart()  
        ' No need to lock in onStart() 
         application("SessionCount") = 0  
    end sub 
    %>

    Note: to know number of current users / session Print    application("SessionCount") variables

    <%= application("SessionCount") %> 

    Saturday, July 13, 2013

    VBScript - ByVal Vs ByRef / VBScript Passing Values ByRef or ByVal

    Let Us See how we can get values by Reference and by Values :

    In VBScript ByRef and ByVal:

    <%
    Function MyFunctionByRef(ByRef Myvalue)
          Myvalue = Myvalue + 1
    End Function

    Dim sendvalues : sendvalues = 3
    Dim MyOutput: MyOutput = MyFunctionByRef(sendvalues)
    Response.write "MyOutput: " & MyOutput  '4
    %>

    <%
    Function MyFunctionByVal(ByVal Myvalue)
         Myvalue = Myvalue + 1
    End Function

    Dim sendvalues : sendvalues = 3
    Dim MyOutput: MyOutput = MyFunctionByVal(sendvalues)
    Response.write "MyOutput: " & MyOutput '4
    %>



    VBScript - ByVal Vs ByRef




    Passing Parameters ByRef and ByVal

    In VBScript, there are two ways values can be passed:
    1) ByVal

    2) ByRef

    Using ByVal, we can pass arguments as values whereas with the use of ByRef, we can pass arguments are references.
    ByVal:

    the parameter is passed by value, thus the subroutine works with a copy of the original.
    ByRef:

    the parameter is passed by reference, thus the subroutine works directly with the original.


    Example: Parameters By Value


    Function GetValue( ByVal var )
    var = var + 1
    End Function

    Dim x: x = 5

    'Pass variable x to GetValue function ByVal
    GetValue x

    Response.write "x = " & x

    Output: x = 5

    Example: Parameters By Reference:


    Function GetReference( ByRef var )
    var = var + 1
    End Function

    Dim x: x = 5

    'Pass the variable x to the GetReference function ByRef
    GetReference x

    Response.write x

    Output: 6

    What is eval() method in Classi ASP VB Script / How to Evaluate a String Dynamically - Change String at Run Time

    Often we need to  Evaluate a String Dynamically , here Classic ASP  /  VB Script provides a power fool method named EVAL(), Let us see how to use Eval() method in Classic ASP / VB Script.


    Const MYNAME = "Deepak Kumar Madheshiya"
    Const MYNAME_HI = "दीपक कुमार मद्देशिया"

    Dim LanguageCode: LanguageCode = 1
    <%=GetString(MYNAME, LanguageCode))

    OutPut: Deepak Kumar Madheshiya

    LanguageCode = 0
    <%=GetString(MYNAME, LanguageCode))

    OutPut: दीपक कुमार मद्देशिया

    Function GetString (MyValues, LanguageCode)

        If LanguageCode = "1" Then
            GetString = eval(MyValues & "_HI")
        Else
            GetString =eval(MyValues)
        End If    
    End Function

    Tuesday, July 9, 2013

    Dynamically create input fields - jQuery

    JQuery Provides,  to add or remove a textbox dynamically. The idea is very simple,  jQuery createElement(), html() and remove() method. See below given example : 


    <html>


    <head>
        <title>Dynamically create input fields - jQuery</title>
        <script src="/js/jquery-1.4.js"></script>
        <link rel='stylesheet' type='text/css' href='/styles.css'>
        <script type="text/javascript">
            var i;
            $(function() {
                var addDiv = $('#addinput');
                i = $('#addinput p').size() + 1;
                $('#addNew').live('click', function() {
                $('<p><input type="text" id="p_new" size="40" name="p_new_' + i + '" value="" placeholder="I am New" /><a href="#" class="mybutton" id="remNew">Remove</a> </p>').appendTo(addDiv);
                    i++;
                    return false;
                });

                $('#remNew').live('click', function() {
                    if (i > 2) {
                        $(this).parents('p').remove();
                        i--;
                    }
                    return false;
                });
            });
            function fillHiddenField() {
                $('#MyTextBoxLength').val(i);
                return true;
            }
        </script>

    </head>
    <body>
    <%
    If request("Submit") <> "" Then

        dim iCount : iCount = Request("MyTextBoxLength")
        For i = 0 to (iCount-1)
          Response.Write  Request("p_new_"&i) &"<br/>"
        Next
        
    End If
     %>
        <h2>
            Dynammically Add Another Input Box</h2>
    <form id="two" name="two" class="asholder" action="test1.asp" method="post">
        <div id="addinput" class="ui-button-global">
            <p>
                <!--<input type="text" id="p_new" size="20" name="p_new" value="" placeholder="Input Value" /><a
                    href="#" id="addNew">Add</a>-->
                <a href="2013-rashiphal-in-hindi.asp" id="addNew" class="ui-button icon arrowright">
                Add</a>
            </p>
            <input type="hidden" name="MyTextBoxLength" id="MyTextBoxLength" value="" />
        </div>
        <input type="submit" class="mybutton" name="Submit" value="Get Result" onclick="return fillHiddenField();" />
    </form>    
    </body>
    </html>


    How to Read RSS feed Using Classic ASP


    Function BinaryToString(byVal Binary)
    '--- Converts binary to text
    '--- Set the return value in case of error
    BinaryToString = ""
    '--- Creates ADODB Stream data
    Dim BinaryStream
    Set BinaryStream = CreateObject("ADODB.Stream")
    '--- Specify stream type data.
    BinaryStream.Type = 1 '--- adTypeBinary
    '--- Open the stream And write text/string data To the object
    BinaryStream.Open
    BinaryStream.Write Binary
    '--- Change stream type to text
    BinaryStream.Position = 0
    BinaryStream.Type = 2 '--- adTypeText
    '--- Specify  unicode data.
    BinaryStream.CharSet = "UTF-8"
    '--- Return converted text
    BinaryToString = BinaryStream.ReadText
    End Function



    Sub GetMyData
    Dim MyhorosignArray : MyhorosignArray = Array ("A","B","C","D","E","F","G","H","I","J","K","L")
    Dim objHTTP, strBuff, objXML, objLst, intNoOfHeadlines, objHdl
    Set objHTTP = CreateObject("Microsoft.XMLHTTP")
    objHTTP.Open "GET", "RSS-FEED-URL", False
    objHTTP.Send
    If objHTTP.Status = 200 Then strBuff = BinaryToString(objHTTP.ResponseBody)
    Set objHTTP = Nothing
    If Len(strBuff) > 0 Then
    Set objXML = CreateObject("Microsoft.XMLDOM")
    objXML.async = False
    objXML.LoadXML(strBuff)
    If objXML.parseError.errorCode <> 0 Then
    Response.Write objXML.parseError.errorCode & " (" & objXML.parseError.reason & ")"
    Else
    Set objLst = objXML.getElementsByTagName("item")
    intNoOfHeadlines = objLst.length -1
    For i = 0 To 11 'intNoOfHeadlines
    Set objHdl = objLst.item(i)
    Ref = objHdl.childNodes(0).text
    Link = objHdl.childNodes(1).text
    Text =  objHdl.childNodes(2).text
            Response.Write Text
    Set objHdl = Nothing
    Next
    Set objLst = Nothing
    End If
    Set objXML = Nothing
    End If
    End Sub

    Thursday, March 22, 2012

    Response.Redirect Vs Server.Transfer



    Response.Redirect Vs Server.Transfer




    Server.Transfer: Transferring to another page using Server.Transfer conserves server resources. The transfer takes place on the server instead of forcing the browser to redirect to a new page. This means fewer HTTP requests coming through and can make your applications run more efficiently. Server.Transfer maintains to original URL in the browser.

    Note:Only data transferred to a second ASP page are the ASP built-in objects and the ASP Error object values from the first request. Any variables declared by the first ASP page are not available in the second ASP page.

    Server.Transfer has several advantages over Response.Redirect:
    1) Because it saves a round trip between the server and the browser it's faster and reduces the load on the Web server.
    2) The Response querystring and form collections are preserved during the transfer. As a result, you don't need to worry about reposting form and querystring data to the new page.

    However, Server.Transfer does have a few disadvantages:

    1) You can only use Server.Transfer to redirect to a page on the same Web server.
    2) You can't pass a querystring to the new page. (However, remember that the querystring passed to the page executing the transfer will automatically be passed along to the new page.) If you try to pass a querystring to the new page, you will trigger an ASP error.
    3) The browser is never notified of the new page, which can cause problems with relative links in some cases.
    Note: Please 3rd point to noted very carefully



    Wednesday, March 21, 2012

    VBScript - ByVal Vs ByRef



    VBScript - ByVal Vs ByRef




    Passing Parameters ByRef and ByVal

    In VBScript, there are two ways values can be passed:
    1) ByVal

    2) ByRef

    Using ByVal, we can pass arguments as values whereas with the use of ByRef, we can pass arguments are references.
    ByVal:

    the parameter is passed by value, thus the subroutine works with a copy of the original.
    ByRef:

    the parameter is passed by reference, thus the subroutine works directly with the original.


    Example: Parameters By Value


    Function GetValue( ByVal var )
    var = var + 1
    End Function

    Dim x: x = 5

    'Pass variable x to GetValue function ByVal
    GetValue x

    Response.write "x = " & x

    Output: x = 5


    Example: Parameters By Reference:


    Function GetReference( ByRef var )
    var = var + 1
    End Function

    Dim x: x = 5

    'Pass the variable x to the GetReference function ByRef
    GetReference x

    Response.write x

    Output: 6


    Tuesday, March 20, 2012

    Create Array in New Style Using VB Script / Java Script



    Create VBScript and JScript Arrays in modern style



    Now we can create Array in modern style in VB script and JavaScript also, using this way we can reduce line of code, to make our program efficiency. For Example:
    Create Array in JavaScript:

    Var NakshtraName
    NakshtraName = new Array("Ashwini", "Bhairini", "Krittika", "Rohini", "Mrigashirsha", "Aardhra", "Punarvasu", "Pushya", "Ashlesha", "Magha", "Purva Phalguni", "Uttara Phalguni", "Hastha", "Chitra", "Swati", "Vishaka", "Anuradha", "Jyestha", "Moola", "Purva Ashadha", "Uttara Ashadha", "Shravana", "Dhanista", "Shathabhisha", "Purva Bhadrapad", "Uttara Bhadrapada", "Revati");

    Create Array in VB Script:

    Dim NakshtraName

    NakshtraName = Array("Ashwini", "Bhairini", "Krittika", "Rohini", "Mrigashirsha", "Aardhra", "Punarvasu", "Pushya", "Ashlesha", "Magha", "Purva Phalguni", "Uttara Phalguni", "Hastha", "Chitra", "Swati", "Vishaka", "Anuradha", "Jyestha", "Moola", "Purva Ashadha", "Uttara Ashadha", "Shravana", "Dhanista", "Shathabhisha", "Purva Bhadrapad", "Uttara Bhadrapada", "Revati")