Sunday, September 23, 2012

How to Put/Create Space in HTML

Hello Everyone,
                         Putting Space in HTML is quite simple, All you need is to put   tag between your text.

So for instance you have a label and a TextBox in your Page, and you need to separate them by giving space between them

    <asp:Label ID="Label1" Text="This is a Label" runat=server/>           // this is my Label


     <asp:TextBox ID=TextBox1 Text="This is a TextBox" runat=server />     //this is my TextBox

Right now If i run this page there will be no gap/space between them so for this I will use &nbsp; tag between these two controls

Like this

     <asp:Label ID="Label1" Text="This is a Label" runat=server/>           // this is my Label
     &nbsp;&nbsp;                                                  //you can use as many &nbsp tag here as you want
     <asp:TextBox ID=TextBox1 Text="This is a TextBox" runat=server />     //this is my TextBox

Now if I run this page there will be space between Label and TextBox, if you want more space than just increase the number of &nbsp tag. thats it

I hope it was informative for you & I would like to Thank you for reading.

Tuesday, September 18, 2012

Bubble Sort Simple Program in C++

 This is a simple demonstration of Bubble Sort, I made this in C++ for my class fellows

You should use Dev C++ Compiler to compile this, this might not work in TC

1. The program will first ask the total number of values
2. Using Bubble Sort, it will sort all the values
3. Finally you will get a answer is sorted form


#include<iostream.h>
#include<conio.h>
main()
{
      int value[10];
      int temp;
      int values;
      cout<<"How many values do you want ? ";
    cin>>values;
    for(int b=1; b<=values; b++)
    {
    cout<<"Enter Value ";
    cin>>value[b];
    }         
              for (int b = 1; b < values-1; b++)
            {
                for (int a = 1; a < values; a++)
                {
                    if (value[a] > value[a + 1])
                    {
                        temp = value[a];
                        value[a] = value[a + 1];
                        value[a + 1] = temp;
                    }
                }
            }
            cout<<"\t\tSorted Answer\n\n";
            for(int b=1; b<=values; b++)
            {
                    cout<<value[b];
                    cout<<"\n";
             }
      getche();
      return 0;
      }

Download a .exe of this project from here


Friday, September 7, 2012

Access MasterPage variable in WebForm

Hello,
     Today we will see how can we access a variable in our WebForm which was created in MasterPage.
     We will create a button in WebForm and when a user click on the button the value of that variable will be assigned to Button Text.

So let's Start

1. First Create a ASP.Net project, by clicking on File menu >> New >> Project

2. From the left menu Select Web and than from right menu select ASP.NET Web Application

3. Click on OK

Now we will add a Master Page, so

4. In Solution Explorer, right click on your project than Add >> New Item

5. Select Masterpage, and click on Add

6. In the code section of MasterPage create a public string name it "msg"


Public String msg="Put any Value";

7. Assign any value to this string you want

Now we will Add a WebForm in our project so

8. Right Click on your project >> Add >> New Item

9. Select WebForm using MasterPage

6. Click on Add, you will be ask to Select a Master Page, so select Site1.Master and click on OK

7. Now in Solution Explorer, right click on your WebForm and click on View Markup

Now here we have to define @MasterType directive
this is important to access any variable in MasterPage

8.  So just below Page Title, copy and paste the following line

         <%@MasterType VirtualPath="~/Site1.Master" %> 


9. Now make a button in your WebForm

10.  Double Click on the button to go into it's Coding

11. From here we can use the Master property and can use that string which we created in Master Page

    Now to change the button text, paste the following line inside Button Method

    Button1.Text=Master.msg;

You can now easily access any variable of MasterPage in any of your WebForm.

If you have other WebForm and want to access variable Created in MasterPage than you will explicitly require to define MasterType directive in all your WebForm.

I hope this was informative for you, and I would like to Thank you for reading.

Sunday, August 19, 2012

Stop Clock Sync with host machine in Virtual PC

Hello everyone,
                        you might have noticed that whenever you change time in Virtual PC on a guest machine, it immediately synchronize it's time with the host machine, this can be very frustrated when you are working on an application which is time sensitive, like I had this problem when I was developing a Task Scheduler in C#

Anyways you can stop the clock synchronization between host machine and guest machine by following these steps

1. Open Virtual PC and start your guest Operating System

After it fully loads

2. Click on Start and than Click on Run and type services.msc

A window will pop-up listed all avalable services

3. Now here we have to find service

  •    Virtual Machine Additions Services Application
4. Right Click on the service and click on Stop

Note: You can also click on properties and set the startup type to Disabled, this way it will never starts at it's own, though you can manually start it later.

5. Close window

Now you can change the time in guest OS and this time it will not try to sync with the Host machine

I hope this for informative for you, And I would Like to thank you for reading

Saturday, August 11, 2012

Read textbox Buttons C#


   1:  private void BtnClick_Click(object sender, EventArgs e)
   2:    {
   3:      DialogResult Result;
   4:      Result = MessageBox.Show("Do you like my blog ? ", "Question", MessageBoxButtons.YesNo);
   5:        if (Result == DialogResult.Yes)
   6:           {
   7:               MessageBox.Show("You clicked on Yes :) ");
   8:           }
   9:         else if (Result == DialogResult.No)
  10:           {
  11:               MessageBox.Show("You clicked on NO  :( ");
  12:           }
  13:    }

In the above code
1. I have created a variable of DialogResult, (this variable will be use to store/identify which button did user press)

2. Than on line 5 we compare if the value in result variable equals to DialogResult.Yes than press

"You clicked on Yes"

Else

"You Click on No"

I hope this was informative for you, and I would like to thank you for reading.