2

here is what i have done so far:

//delcare html:

<div class="success" id="divStatus" style="display:none;" ><a href="#" class="close">&times;</a></div>

asp.net code behind:

 ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "_key"+this.UniqueID, "$(function() { $('#divStatus').html('" + msg + "').show().fadeIn(9000).fadeOut(9000); });", true);

//css class:

.success
    {  
        display:block;  
        color: #4F8A10;
        background-color: #DFF2BF;
    }

there is only logical explanation i think of is that, there is no css class(.success) in the >> #divStatus in $function .... is defined?

updated end

i am trying to add an class to the below selector but not sure if this is the right way of doing, any help?

here is what i tried doing but i don't see the the class is added and no action ( expect to see some colours)

"$(function() { $('#divStatus').addClass('success').html(.........

here is the full code i am doing in asp.net in code-behind.

ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "_key"+this.UniqueID, "$(function() { $('#divStatus').html('" + msg + "').show().fadeIn(9000).fadeOut(9000); });", true);
3
  • 2
    .show().fadeIn(9000).fadeOut(9000) that's not gonna work like you think it is (ie: chaining the calls does not make fadeOut wait for fadeIn to finish). Commented May 7, 2012 at 3:53
  • it would be better to help if u add some detailed code in jsfiddle or jsbin.... Commented May 7, 2012 at 3:58
  • i have updated my question, i am doing this from asp.net code-behind and i know it will work from plain html page. Commented May 7, 2012 at 14:09

2 Answers 2

1

This might be what you're looking for

HTML

<div id="divStatus"></div>

CSS

#divStatus{
    display: none;
}

.success{
    color: red;
}

JavaScript

$(function() {
    $('#divStatus')
        .html('hello')
        .show('fade', 2000, function(){
            $(this).addClass('success');
        })
        .hide('fade', 2000);
});

an alternative to this could be

$(function() {
    $('#divStatus')
        .html('hello')
        .show('highlight', 2000, function(){
            $(this).addClass('success');
        });
});
Sign up to request clarification or add additional context in comments.

1 Comment

i have updated my question, i am doing this from asp.net code-behind and i know it will work from plain html page.
0

You would probably need to provide more information. The addClass works basically just like you have. Here is a fiddle to display the change you want on a button click:

http://jsfiddle.net/lucuma/6mSXP/

Example: $('#status').html('it worked').addClass('success');

5 Comments

i have updated my question, i am doing this from asp.net code-behind and i know it will work from plain html page.
Is the registerclientscriptblock being called in a post back?
i have this ScriptManager.RegisterClientScriptBlock... code in the event when the user clicks on the button i display that div
answer to your question , yes it being called
I think you should create a plain old javascript function: function showConfirm(msg) and then call that in your post back.. That way you can put an alert in there and see if it is actually being called.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.