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

Top 5 Contributors of the Month
david stephan
Post New Web Links

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

Posted By: Amit Mehra     Posted Date: November 18, 2009    Points: 2   Category :JQuery
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

View Complete Post

More Related Resource Links

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



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


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..

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="

ASP.NET Pipeline: Use Threads and Build Asynchronous Handlers in Your Server-Side Web Code


Fortunately for developers, threading in ASP.NET is a lot easier than it was in ASP. In this article, the author takes a look at threading in the ASP.NET HTTP pipeline, and explains how threads are managed efficiently without the involvement of the developer. The article considers how the common language runtime threadpool is used by ASP.NET to service requests, looks at the pooling mechanisms used for handlers, modules, and applications, and covers both IIS 5.0 and IIS 6.0 and how they differ in their approach to request processing and thread allocation. Finally, how and when to use asynchronous handlers is discussed for developers who still need to use threads in their own applications.

Fritz Onion

MSDN Magazine June 2003

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

Can I invoke a client side script from server side code

Hi is it possible to involk a client side script from the server side code without any interaction from the client side?Such as a popup or alert box?I know I can code this with the page load or the click event, I would like to call the alert from within my serverside code and trigger the action from there.Thanks

How to get configuration information in side server-side code

I'm relatively new to writing code for sharepoint 2010, and one thing I'm curious about is how/where can I store configuration information, so that if I code on 1 platform and push to another, how do I keep things like the weburl, sites, lists, etc in a config file?  Is there a standard config file to use, or would it always be the web.config for the entire system? Specifically, if i start up code, how can I find a) what is the current weburl I'm on, b) what site/sitecollection, and c) a list of all lists? thanks  Rocky Sanders

convert client vbscript code to server side

Hi There, we have some .htm pages with client side vbscript,the code is pasted below, we want to get this page run on the server side so that we can access this from a URL, can you please advice how convert this code to be able to run on the server side. Client side code: <HTML><HEAD><TITLE>Select Module</TITLE> <SCRIPT LANGUAGE="VBScript" ><!--     Option Explicit        Dim College    Dim Modules    Dim ModulesArr    Dim counter    Dim MyModules         Set College = Top.App.ActiveCollege    Set Modules = College.Modules     'Sorts the ModulesArr Array by module name.    Sub SortModules(StartPosition, EndPosition)        Dim I, J        Dim CurrName, CurrIndex        For I = StartPosition to EndPosition            J = I            CurrIndex = ModulesArr(J, 0)            CurrName = ModulesArr(J, 1)             'while Mod

Can you call a javascript function from code behind?

Call you cal a javascript function from the code behind? If so how??? 

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

write server side code in External JS files

Salam To All,for my JS code, some times i need to organize my code, so i prefer to put some of javascript functions in external js files and  include it in my page as well.but i am face a problem if i need to write some .Net code especially to Get the Client ID for any of .net controls.so do you have a way to write the following code in External JS file?('#<%= this.ddlMake.ClientID %>').change(function(

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
            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))

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.



Calling Javascript confirm from server-side



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:ImageButton ID="imgdelete"   runat="server" ImageUrl="~/Images/DeleteNew.bmp"  Width="20px" Height="20px" ToolTip="Delete" CommandName="Delete" CommandArgument='<%# Container.DataItemIndex + 1 %>'/>

Make a C# WinForm Call a JS code in a Data server??!!

I have a situation as follows:
My company has its Customers Data stored in a server, and we as employees use Internet Explorer to find the data needed through a page that contains some textboxes to supply info to the server and some other textboxes that shows Data retrieved from server. So fro example I put the customerID in a textbox, press the search button near this textbox, and I get the customerName and customerAge and so on in another textboxes in the same webpage. I konw this is done via JavaScripts.

I hope the scene is clear, Now when I need to print a report about certain customer I have to copy/paste every single textbox content to Word individually.

So I know how to export from C# to Word or at least to Excel .., But is it possible to make a C# WinForms App that can read the contents of these textboxes OR call the JS function that is executed when I press the (Search) button shown in the IE WebPage.

I dont know if my question is clear enough but I hope you can help me. Any help would be appreciated.
Thanks in advance

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