Wednesday 4 July 2012

Add Controls Run time in VB.NET & C#


hi............
Mostly we make control design time, we handle many event like click, mouseover,moueout etc. This is a easy process for design time because there is not any need to attach event handler visual studio attach necessary code automatically.
You can add control on run time………… for do this you will have to perform following steps
  • Make an object of relevant control
    eg. Button btn =new Button()      [C# ]
          dim btn as new Button()         [VB.NET]
  • After make an object of control you have to manage control property
    eg. Location,size,backcolor,text etc
  • You can also attach events..
Add an Button in C#
  Button btn = new Button();
            btn.Text="Click";
            btn.Location=new Point(100,100);
            btn.Click +=new EventHandler(btn_Click);
            this.Controls.Add(btn);
     following function will catch and handle button click event….
private void btn_Click(object sender,EventArgs e)
        {
            MessageBox.Show("Called");
        }
Add a combo box in vb.net
            Dim com As ComboBox
        com = New ComboBox
        com.Items.Add("one")
        com.Items.Add("two")
        com.Items.Add("three")
        com.Location = New Point(150, 100)
        AddHandler com.SelectedIndexChanged,AddressOf com_click
        Me.Controls.Add(com)
following function will catch and handle combo box
selectindexchange event….
       Private Sub com_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MsgBox("Called event")
    End Sub
       

Monday 2 July 2012

How to Retrieve records from ms access using date field in condition

Hi...... there
As you know SQL is a language which enable us to use database. If you've knowledge of SQL then you can operate any database software, for achieve this you just need to know how to run SQL Statement in that DBMS package
One thing you must know that there are some different in SQL in different DBMS package they use different data type and size, they treat date field as different way so if you want to use SQL you must know what are the SQL specification for that DBMS package
Develop Raj Kumar
Form of project
  • MS Access treat date field differently from SQL server
  • If you want to make a condition based on date you'll have to put date between ## e.g #7/28/2010
  • Import System.Data.OleDb name space for oledb class

     

     

     

    Save Button Code

    Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=your path")
            Try
                con.Open()
                Dim dd As String
                dd = DateTimePicker1.Value.Date
                Dim com As New OleDbCommand()
                com.Connection = con
                com.CommandText = "insert into stu values(" & TextBox1.Text & ",'" & TextBox2.Text & "','" & dd & "')"
                com.ExecuteNonQuery()
                MsgBox("Saved")
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

    Search Button Code

     Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your Path")
            Dim da As New OleDbDataAdapter("select * from stu where dob=#" & DateTimePicker1.Value.Date & "#", con)
            Dim ds As New DataSet
            da.Fill(ds)
            DataGridView1.DataSource = ds.Tables(0)

Friday 8 June 2012

How to save a file from HTML File Control in AJAX Section Using ASP.Net with C#



    •     AJAX stands for Asynchronous  Java script and XML  
    •    AJAX enable a page asynchronously post back a page.  
    •   Only required part load from server instead of entire page so its   increase web performance.
    • Some control which are design for post back like file browser which can’t load a file if its not post back so you can’t upload a file when it’s in AJAX section.

        For upload a file in AJAX section using file browser you need to register a button for post back if user will click on than button then all page will be reloaded.
      <asp:UpdatePanel ID="U1" runat="server">
                <ContentTemplate>
      ....................................
      ....................................
               </ContentTemplate>
         <Triggers> 
             <asp:PostBackTrigger ControlID="saveButton">
         </Triggers>  
      </asp:UpdatePanel> 
      Here is your html code i leave ...... for your content Savebutton is a which post back entire page
      So i registered this button in trigger section post backTrigger register control which have to post back.....

Wednesday 6 June 2012

Create Album Using Java Script with fade effect



Hi.................
This post will help you to make a picture album.Pictures of album will change during a second internal.
I have done this with the help of java script.
  • This post will create a static album in nature you can't add a new image at run time if you want to add or remove image you will have to change java script code.
  • Save your picture in a folder and rename all picture into 1 to increasing order e.g (1.jpg , 2. jpg ,3,jpg...)
  • Count no. of picture in your folder because I'll use this number in java script code block
  • I used a timer which will run continue you can not stop it