.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Server Side Javascript in ASPX page

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :Windows Application
 

Hi,

We have a Classic ASP application. We need to migrate this Classic ASP application to ASP.net.

We have extensevly used Server side Javascript in our Classic ASP Pages.

Basically we have mix of both VBScript and Javascript in same ASP pages.

Need help in migrating such ASP pages (using serverside VBScript and Javascript).

Migrated Code samples will be most welcome.

For migration,  we are planning to use : ASP to ASP.NET Migration Assistant

Example below -

  • Sample.htm : These kind of HTML pages are hitting ASP pages to get response from server.
  •  

    <html> 
    <head> 
    <script> 
    var strURL = "http://localhost/Samples/"; 
     
    function test0(methodType){ 
     
            var oRequest = new ActiveXObject("Msxml2.XMLHTTP"); 
            var url = strURL + "Sample.asp";  
             
            oRequest.open(methodType,url,false);  
            oRequest.send(null);  
     
            var resp = oRequest.responseText; 
             
            alert(resp); 
    } 
     
    </script> 
     
    </head> 
    <body> 
    <input type=button onClick="test0('GET')" value="Click me - Get Method"/> 
    <br><br> 
    </body> 
    </html>
    • Sample.asp : This is sample ASP page where we are using both servreside VBScript


      View Complete Post


    More Related Resource Links

    Server Side Javascript in ASPX page

      

    Hi,

    We have a Classic ASP application. We need to migrate this Classic ASP application to ASP.net.

    We have extensevly used Server side Javascript in our Classic ASP Pages.

    Basically we have mix of both VBScript and Javascript in same ASP pages.

    Need help in migrating such ASP pages (using serverside VBScript and Javascript).

    Migrated Code samples will be most welcome.

    For migration,  we are planning to use : ASP to ASP.NET Migration Assistant

    Example below -

    • Sample.htm : These kind of HTML pages are hitting ASP pages to get response from server.

     

    <html>
    <head>
    <script>
    var strURL = "http://localhost/Samples/";
    
    function test0(methodType){
    
    	var oRequest = new ActiveXObject("Msxml2.XMLHTTP");
    	var url = strURL + "Sample.asp"; 
    	
    	oRequest.open(methodType,url,false); 
    	oRequest.send(null); 
    
    	var resp = oRequest.responseText;
    	
    	alert(resp);
    }
    
    </script>
    
    </head>
    <body>
    <input type=button onClick="test0('GET')" value="Click me - Get Method"/>
    <br><br>
    </body>
    </html>
    • Sample.asp : This is sample ASP page where we are using both servreside VBScript and Javascript.

     

    &

    call JavaScript - jQuery code from ASP.NET Server-Side

      
    jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

    Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

    call JavaScript - jQuery code from ASP.NET Server-Side

      
    jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

    Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side

    Call Server Side Code from Javascript in VB.NET

      

    Hi

    Could anyone give me an example how to call Server Side Function from javascript and then I want to call that javascript function on Button OnClick () Event.


    Thanks in Advance

    Shabbir



    Closing Javascript Modal dialog window after server side event processing

      

    Hello Friends..


    Please tell me how to close Javascript ModelDoalog Window.. after Server Side event Processing .

    Basically i want close window in  finally Block After sucessfulll Updation.


    AMit..... InnocentInnocentInnocentInnocentInnocentInnocentInnocent


    calling a web service on a remote server from an ASPX page

      
    hi, I want to call a web service on a remote server. I've done "add web reference" in my project, and VS2005 has created the .discomap and .WSDL in the App_Web_Reference folder. When I try add the namespace representing the web server (the name I created when I added the web reference) by "using XXXXX;" the code does not compile because XXXXX is not defined. Have I missed any steps? thanks, -me

    calling a web service on a remote server from a ASPX page (web site project VS2005)

      
    HI,I am maintaining a web site project in VS2005 and have to call a new web service on a remote server. I've done add web reference, and created the .wsdl and .discomap files in the app_webReference folder.  When I try to create a object representing the web service in the code ( wsnamespace.serviceName ws = new wsnamespce.serviceName(); ) the code wouldn't compile.The web site project is already calling other web services. When I right click on the type representing the web service and "go to definition" it takes me to a proxy class (derived from of course SoapHttpClientProtocol) in the metadata. I think this is what's missing for  the new web service i'm trying to call. Have I missed any steps?Thanks in advance.-me

    call a server side C# method from javascript

      
    http://forums.asp.net/t/1591584.aspx Hi friends, can anyone provide me the C# code of the above post answer(pls go to the link)..i didnt understand the VB code... i dont know VB.. my problem also same.. i have a method in a class in App_Code folder... i want to call that method from javascript.. the method takes one parameter which is list box cotrol id... the list box control also available in the same page..   Please can anyone help me on this..

    Automatically inserting server-side page events into C# when using code separation

      
    I know this is a really basic question and I have spent the last half hour trying to find an answer so please forgive me if this has been asked before (it probably has)....When I create a web page with the C# code placed in a separate file I can't seem to easily add page events (apart from Page_Load). When I open the C# class code for the page all I see in the two drop-down boxes above the code is "Default" (with no other options in the drop-down) in the left-hand box and "ApplicationInstance,form1,Page_Load(object sender,EventArgs e),Profile" in the right hand box. I can't see a way to create the code for the other page events from either of these drop-downs.If I keep the C# code in the same file (i.e., not use code separation) everything works fine - I see "Server Objects & Events, Page, Form1, etc..." in the left hand drop-down and I can create new events in the right drop-down when either Page or Form1 are selected in the left box.Am I missing something really obvious?Many thanks for any suggestions

    Calling a Server side function from Javascript without using PageMethods

      
    Good Day alli have used PageMethods to access the server side functions in javascript , but now my problem is that with pagemethods your controls will not go throught the full page lifecyle and these leads me to have "Object not set for an instance of an object" error. Now can someone come with a differnt approach without using pagemethods. What i want is to call a server side function , i dont want to pass any parameters to itthanks

    Capture query string value in javascript in aspx page

      

    I have a simple problem that I cannot remember how to solve.  I am sure it is very easy.  Following is my code:

    <asp:Image id="btnAddNew" runat="server" ImageUrl="~/images/btnAdd.png" OnClick="javascript:window.open('DetailLocation.aspx?projectID=&locationID=','newWindow','width=600,height=600,scrollbars=yes');" />

    In the OnClick event I have embeded a javascript function that works as expected. However, I need to embed a querystring value into the javascript function variable:

    DetailLocation.aspx?projectID=??

    I thought I could just embed <%=Request("projectID") %> in there, but the compiler does not like it. 

    Thanks in Advance.

     


     


    Problem Creating Server Side Javascript

      

    I have a custom control which creates client side Javascript in order for it to function. When the property .OnSelectScript is wrapped in an if...then that tests its length, the value of .OnSelectScript appears to be ignored when the Javascript is being generated. However, when I set the .text value of a test label to Javascript, it appears there. I have confirmed that the statement *does not* appear client side when I view the source for the page.

    Property declaration for the control

        Public Property OnSelectScript() As String
            Get
                Return _OnSelectScript
            End Get
            Set(ByVal value As String)
                _OnSelectScript = value
            End Set
        End Property
        Private _OnSelectScript As String

    Full SUB as designed

        Protected Sub Page_Load() Handles Me.Load
    
            Dim ClientSideJavaScript As New StringBuilder
    
            LabelSelectorTitle.Text = Me.Title
            Call LoadData()
    
            ClientSideJavaScript.Append("/*File: Test Selector.aspx.vb Sub: Page_Load()*/" & Chr(10))
            ClientSideJavaScript.Append("function setValue(ParentPopup, TargetDisplayControl, NewDisplayValue, TargetTextboxControl, NewKeyValue) {" & Chr(10))
            ClientSideJavaScript.Append("document.getElementById(TargetDisplayControl).inn

    Server Side Code Not Firing After Javascript Function

      

    I have a group of buttons and a text box which I have been using for paging. The user is able to type a number into the text box and either click the "Go" button or hit "Enter" for the paging to occur. To have the "Enter" button work I had to turn the "UseSubmitBehavior" property to false for all of the buttons except the "Go" button.

    Now I am trying to add a javascript function that shows a confirm box when the user clicks on a paging button. If the function returns true, the client side code should run. If the function returns false then nothing else should run. I have been successful with getting this to work for the "Go" button but it won't work for any of the other paging buttons because I have "UseSubmitBehavior" set to false. Can anyone think of a way to get this to work with the other buttons?

    Thanks in advance for the help.

    <asp:Button ID="btnFirstPage" runat="server"  Text="<<"  OnClick="PagerClicked" OnClientClick="return unsavedChanges();" UseSubmitBehavior="false" />
    <asp:Button ID="btnPreviousPage" runat="server"  Text="<"  OnClick="PagerClicked" OnClientClick="return unsavedChanges();" UseSubmitBehavior="

    Determine CSS class, set by javascript, server-side

      

     I have a website and I use javascript/jQuery to change the CSS classes associated with various controls on the page to hide and displey them based upon user selections.  I want to be able to determine the current Css class for an item on my page when the page is posted back to the server.  Is there any way to determine the current Css class for a control on the server when it's been changed using javascript client-side?

    Any suggestions would be greatly apprciated.

    Thanks.

    K


    Adding a server control on aspx page does not add events in aspx.designer.vb file

      

    Hi,

    I work in VS 2008. Whenver I add a server control(Label) and set it properties in aspx.vb and build the solution, I get the error "Label1 not declared". While analyzing this issue I noticed that the event handler statements for the Label1 where not added in the designer.asp.vb file. These statement would actually be added automatically when I drag and drop a control to my webpage.

    I would also like to inform the scenario after which this problem came to me. I was working in VS 2008 , VS 2005 and VS 2003 in the same machine.Could this have caused the issue ? Please advise.

    Now each and everytime when I add a control, I am adding the "With Events" code in the designer page to make my build succesfull which makes me to spend more efforts.

    Please advise if any settings have to be changed.

    Thanks,

    Arunesan


    Calling Javascript confirm from server-side

      

    hello,

    This normally should not be difficult but I am just starting javascript.

    The case is very simple.Before I delete  the record from the gridview ,I want to call the confim windows in order to give the user the opportunity of ok oe cancel.

    in the client side I do not have any reference to javascript.

    The first touch with it ,it happents in the following code:

     public void grdomas_RowDataBound(Object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    ImageButton  l = (ImageButton)e.Row.FindControl("imgdelete");
    
    
                    l.Attributes.Add("onclick","javascript:return " + "confirm('Are you sure you want to delete this record? ')");
                }
    
    
                
            }
    The image button is defined in the aspx as:
    <asp:TemplateField>
    <ItemTemplate>
    <asp:ImageButton ID="imgdelete"   runat="server" ImageUrl="~/Images/DeleteNew.bmp"  Width="20px" Height="20px" ToolTip="Delete" CommandName="Delete" CommandArgument='<%# Container.DataItemIndex + 1 %>'/>
    &

    How to close the sharepoint modal dialog and refresh the parent page using Server side API?

      
    I am trying to find a way to close a modal page that has been opened with the click event of ribbon control. Once the modal dialog is opened, I'm showing 'OK' button for the user to confirm some action on the respective list item. If the user clicks on 'OK', I'm performing some action on the listitem using server side code. Here the problem for me is, once the action is completed on this listItem, I need to close the dialog and refresh the parent page (AllItem.aspx) using *sharepoint server side
    API*

    I'm aware that for closing the dialog we have JS code "SP.UI.ModalDialog.commonModalDialogClose". But this is not useful for me, because I should first run some action on the listitem and once that action is complete, then only I should close this dialog.

    Categories: 
    ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
    Sql Server  SharePoint  Silverlight  Others  All   

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend