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.