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

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

how to apply a css class on html span tag in javascript?

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :ASP.Net


I'm trying to apply a css class on an html span tag in javascript, like below-

$('#company-info').css("class", "help");

But this line of code isn't working!

Can anyone let me know the right way of doing this?



View Complete Post

More Related Resource Links

ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

This post covers another useful improvement in VS 2010 - HTML/ASP.NET/JavaScript snippet support. Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.

Visual Studio has supported the concept of "snippets" for VB and C# in previous releases - but not for HTML, ASP.NET markup and JavaScript. With VS 2010 we now support snippets for these content types as well.

Re-positioning an HTML container with javascript onresize with a Master page.


I have an HTML <div> container that I float to the right of a gridview.  When the browser window is maximized, it looks fine.  When minimized, the gridview positions below the floating container and most of the data is pushed off the bottom of the browser - you have to scroll down to see it.

If I position the floating container above the gridview it looks fine in a minimized window, but looks real bad when maximized.

What I want to do is use a javascript: onresize event to re-position the floating container up or down depending on the window.inner.width AND do it with a Master/Content page structure AND do it for only the one page where needed.

I can capture the onresize event and display the window dimensions but haven't figured-out how to do it with a Content page that still uses the Master page.  I think I'm having a very "thick" week...

- Tinker


return class to javascript from webservice?

Hi,I know i've seen a tutorial for this, but can't locate it anymore. I have a class Employee in c# side, I also have a webservice where I pass in an ID# and an Employee object is returned. Now I want this object returned to Javascript code, I know I've seen it done before, can someone point me to a tutorial that shows something like this being done. I'm using the MicrosoftAjax.js file.Thanks.

Load Javascript/CSS from C# Class Library

Can anyone help me figure out how to load Javascript/CSS from my Class Library onto my .aspx pages? Is it possible?Thanks

Getting Html.TextBoxFor Value on client via Javascript

I want to get the value of a inputText createdBy Html.TextBoxFor via Javascript. But no matter how much I type in it, the input does not get a value and thus the javascript generates an error. Can I do this, if so how?

Asp.net MVC: How to call javascript function in Html.ActionLink

When I edit single recored in page, I use checkbox to get a selected row not every row with an actionlink element, but it seemed I cant make this way happen through calling javascript code(function GetSelectedRow() should return an id). Could anyone have a nice idea?<head runat="server"> <title>Index</title> <script type="text/javascript" language="javascript"> function GetSelectedRow() { var a = 0; var chkBoxes = document.getElementsByName("chkSelect"); var count = chkBoxes.length; for (var i = 0; i < count; i++) { if (chkBoxes[i].checked == true) a = chkBoxes[i].primaryKeyID; } return a; } </script> </head> <body> <div> <span style="width:20%"> <%: Html.ActionLink("Add", "Create")%> </span> <span> <%: Html.ActionLink("Edit", "Edit", new { id = GetSelectedRow()) %> </span> <span> <%: Html.ActionLink("Detial", "Details", new { id = GetSelectedRow() })%> </span> <span> <%: Html.ActionLink("Delete", "Delete", new { i

why the ValidateRequest dose not work when html tags had sent by __doPostBack method in javascript

hi friends.why the ValidateRequest dose not work when  html tags had sent by __doPostBack method in javascript.var encodedAllScripts="<html><td></td></html>"; __doPostBack('getHtmlData', encodedAllScripts);

why the ValidateRequest dose not work when html tags had sent by __doPostBack method in javascript

hi friends.why the ValidateRequest dose not work when  html tags had sent by __doPostBack method in javascript.<script>var encodedAllScripts="<html><td></td></html>"; __doPostBack('getHtmlData', encodedAllScripts);</script>

catch the html button click event on a class file including html text box value.


I want to catch the html button click event on a class file including html text box value..

<p><input name="" type="text"  value="Enter Name*"/></p>
<p><input name="" type="text"  value="Enter Email*"/></p>

  <input name="Input" type="submit" value="Submit" />

plz tell me how can i do this..

Programmatically generating html report using ReportExecutionService class fails


Hello All,

I am utilizing the ReportExecutionService class in MSRS 2008 to programmatically generate reports in a .NET Windows program. I have two Web References, one for ReportingService2005.asmx and one for ReportExecution2005.asmx. I am using ReportExecution2005 namespace to instantiate the ReportExecutionService object.

The problem is that generating report content using the ReportExecutionService.Render method is not working consistently. It works a few  times and then throws a 
"Client found response content type of '', when expected 'text/xml'. This is happening for reports that worked great on a prior test (same report name, same path, same parameters). Does anyone know if I need to change any settings in SSRS to correct this issue. Below is the code

ReportExecutionService res = new ReportExecutionService();
res.Timeout = System.Threading.Timeout.Infinite;
res.Url = url.vvlu_char_vlu_cd.ToString();

res.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Render arguments
byte[] result = null;
string reportPath = @"../../../Stuff";
ExecutionInfo ei = new ExecutionInfo();
ExecutionHeader eh = new ExecutionHeader();
res.ExecutionHeaderValue = eh;

string format = "HTML4.0";
string devInfo = @"<DeviceInfo><Toolbar>False</Tool

How to minify html , css , javascript ( removing white spaces etc )


i am looking for a tool which will minify my code when publishing website


or it may be run time minify too if not using too much cpu power



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.



Javascript function call in HTML+VB?


Hi, i try to call a VB.NET function in my HTML body tag

<body onunload = "if (screenTop > 9999) call Session_End;">


Where Session is my Public VB.Net function in the Global.asax but nothing happen. Do I have to write something like "<script type=\"text/javascript\">?.


Using JavaScript class AND cssClass



I'm using some JavaScript that's called by the class function within a hyperlink control:

<asp:HyperLink ID="HyperLink_MenuSubLink_AddNewOfficial" runat="server" class='colorbox_AddNewOfficial' NavigateUrl="~/secure/club-officials/add-new-official.aspx">Add New Official</asp:HyperLink>

Thing is, I also want to apply the styles I've created for this and other links like it using:


But if I add that, the JavaScript stops working.

Any thoughts?

Thanks as always

how to do a javascript alert from a another public class


I'm using the ReportGenerator.cs class and this class is referenced from the actual calling page Default.aspx and Default.aspx.cs

using GeneraReport;

in the Default.aspx.cs

and the code in GenerateReport.cs:

namespace GeneraReport
    public class ReportGenerator

This namespace has no reference to Page

However I need to be able to do the following in the public class:

      if (dt.Rows.Count == 0)
                        string Script = "";
                        Script += "<script language=JavaScript id='NoRows'>";
                        Script += "alert('No Rows Found in Query');</script>";




I am trying to learn how to pass a JavaScript object to a server side class and have been successful when it is a simple JavaScript object.  

Suppose I have this Person class:

public class Person
  public string FirstName { get; set; }
  public string LastName { get; set; }
  public string Address { get; set; }
  public string City { get; set; }
  public string Zip { get; set; }

And this web service method:

  public void AddPerson(Person NewPerson)

On the client I can create a JavaScript object like the one below and then pass it to the server. On the server side the Person class will have all properties populated by the values in the JavaScript object.

"{"NewPerson":{"FirstName":"Jon","LastName":"Doe","Address":"15 Stanley Road","City":"AnyCity","State":"AnyState","Zip":"55555"}}"

This all works fine and as you can see the JavaScript object and the Person class have no collection (array) properties.  

However, I would like my Person class to have a collection of phone number. So I person could have a home

html/javascript (jQuery)/ajax patterns question


My presentation layer (UI) will consist of pure html (no webforms) javascript, jquery making calls to (Ajax enabled) WCF services. can I use MVC (in my presentation layer) in this context or not?


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