Click here to Skip to main content
12,633,985 members (27,999 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET Javascript jQuery , +
.cs

protected void  form_submit_Click(object sender, EventArgs e)
    {
        String str = "$('.txt').style.border-style=none;";
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "chp", str.ToString(), true);
    }

.aspx

<asp:TextBox ID="txtname" runat="server" BorderColor="#96A6C5" CssClass="txt">
Posted 21-Sep-12 8:06am
Updated 21-Sep-12 8:07am
DaveAuld191.4K
v2
Comments
Sergey Alexandrovich Kryukov 21-Sep-12 13:09pm
   
Your str.ToStrings() shows that you don't know the very basic. I would not advise you to go in for ASP.NET before you make yourself comfortable in very elementary programming techniques.
--SA
Sandeep Mewara 21-Sep-12 13:50pm
   
I doubt if this is a valid attribute of style: border-style
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I don't think your jQuery string is correct. Try this:

String str = "$('.txt').css('border-style', 'none');";


On another matter, SA is correct: you don't need to and shouldn't .ToString() a string.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

I would advise to use the scripts:
$(.txt).addClass("withBorder");
// and
$(.txt).removeClass("withBorder");


Your ".txt" CSS class should be without the borders, and the class "withBorder" (should be named like that, without '.'), should define some border. This way, you can switch between bordered and non-bordered style leaving the rest of styles the same, using the JavaScript lines shown above.

Please see:
http://api.jquery.com/category/css/[^].

The problem could by somewhere else. For example, the selector ".txt" should be in quotation marks and the class with such names should exist in styles you are using. Do you have this class? There could be something else — your sample is incomplete.

Please see:
http://api.jquery.com/class-selector/[^].

And pay attention for my comment to the question, if you want to avoid frustration and lost time.

—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161208.2 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100