Question: I am using a jquery to slide a div "slidingDiv" when an anchor "show\_hide" is clicked. I am wondering if i can show the div open when the page is loaded. Because i have textboxes in the div and want to have some text when the page is loaded sometimes. 

```
$(document).ready(function()
{
    $(".slidingDiv").hide();
    $(".show_hide").show();

    $('.show_hide').click(function()
    {
        $(".slidingDiv").slideToggle();
    });
});

```

How can i do that using c#, asp.net..

Thank you!

Answer: 
Ha, now I see what is bothering you. Your problem is either onResume or onCreate happens second time and this resets your image to your default value you set in your XML. You can simply log and see which of these occurs. Once you see where your image is returned to default, simply create field in your activity class which will remember your current image id or what you want. Something like this

```
private int currentImage = R.drawable.firstImage;

public class MainActivity extends Activity{

   protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);

    static ImageButton mGetClickTime;
    mGetClickTime.setImageResource(currentImage);
        mGetClickTime.setOnClickListener(new View.OnClickListener() {
        mUpdateBackground();
        }
    }
   }

public static void mUpdateBackground() {
    int[] imageIds = { 
            R.drawable.bg1,
            R.drawable.bg2,
            R.drawable.bg3,
            R.drawable.bg4,
            };
    Random generator = new Random();
    randomImageId = imageIds[generator.nextInt(imageIds.length)];
            mGetClickTime.setImageResource(randomImageId);
            currentImage = randomImageId;
    }

```

Hope this helps and enjoy your work.
I got the answer from this thread: [Android: What's the best hierarchy for this app?](https://stackoverflow.com/questions/16634598/android-whats-the-best-hierarchy-for-this-app)

The key was learning the concept of checking if an object is null before calling it. 

The code I used was this:

```
    if (mGetClickTime != null) {
        Log.d("mGetClickTime: ", "is not null");
        mGetClickTime.setImageResource(randomImageId);
    }
    else {
        mGetClickTime = (ImageButton) findViewById(R.id.clicker);
        mGetClickTime.setImageResource(randomImageId);
        Log.d("mUpdateBackground", " was null");
    }

```