Pavan

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • in reply to: Set video on my website home page #5221
    Pavan
    Member

    I think that you can show a video as background with the help of some css and styling such as:

    <body>
    <div style="background:red;height:100px;width:100px;position:absolute"">
    </div>
    <video width="100%" height="100%" style="position:absolute;
    z-index:-1" controls autoplay>
      <source src="movie.mp4" type="video/mp4">
    </video>
    </body>
    in reply to: What is EnableViewStateMAC? #3458
    Pavan
    Member

    Its a page directive attribute that is used for security point.

    true if the view state should be MAC checked and encoded; otherwise, false. The default is true.
    A view-state MAC is an encrypted version of the hidden variable that a page’s view state is persisted to when the page is sent to the browser. When this property is set to true, the encrypted view state is checked to verify that it has not been tampered with on the client.

    in reply to: Need to convert longs web url's to short url's #3440
    Pavan
    Member

    Hello Nitesh,
    This is very useful for posting our sites url on different sites and on forums because they restrict that site url with in specific length.
    Below is the code:

    public static string MakeTinyUrl(string Url)
        {
            //pass an url into this function and get the created tinyurl value as output
    
            try
            {
                string Result = Url;
    
                //only process if > 26 else keep same url
                //reason being tinyurl produces 26 char lengths 
                //so no point if url already <= 26
    
                if (Url.Length > 26)
                {
                    if (!Url.ToLower().StartsWith("http") && !Url.ToLower().StartsWith("ftp"))
                    {
                        Url = "http://" + Url;
                    }
                    System.Net.WebRequest request = System.Net.HttpWebRequest.Create("http://tinyurl.com/api-create.php?url=" + Url);
                    System.Net.WebResponse res = request.GetResponse();
    
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(res.GetResponseStream()))
                    {
                        Result = reader.ReadToEnd();
                    }
    
                }
    
                return Result;
    
    
            }
            catch (Exception ex)
            {
                //if any exception just return the original Url seeing this is still valid as an url
                return Url;
            }
        }
    

    I am using in this example a Textbox and button you just type url in Textbox and press submit button then it will display a tiny url just above the Textbox . Simple copy the url and open in web browser.
    Like i am using Url:
    http://www.authorcode.com/your-first-facebook-windows-application-in-c/

    Result Tiny Url:
    http://tinyurl.com/6oouhqd

    
    
        protected void Button1_Click1(object sender, EventArgs e)
        {
            string Result = MakeTinyUrl(txt_url.Text);
               
            Response.Write(Result);
        }
    
    
    Pavan
    Member

    Hi Nitesh,
    Encrypt and Decrypt Connection Strings is very usefully for security point.Like when we are developing a application which secured then connection string Encrypt and Decrypt is one of steps.

    Define these string at top of page before page load.

    
    string provider = "RSAProtectedConfigurationProvider";
    string section = "connectionStrings";
    
    

    Encrypt connection string code below:

    
      public void Encrypt_connection()
        {
    
            Configuration confg = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
            ConfigurationSection configSect = confg.GetSection(section);
            if (configSect != null)
            {
                configSect.SectionInformation.ProtectSection(provider);
                confg.Save();
            }
        }
    
    

    Decrypt connection string code below:

    
    
     public void Decrypt_connection()
        {
            Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
            ConfigurationSection configSect = config.GetSection(section);
            if (configSect.SectionInformation.IsProtected)
            {
                configSect.SectionInformation.UnprotectSection();
                config.Save();
            }
        }
    
    
    in reply to: Moving ViewState to the Bottom of the Page #3432
    Pavan
    Member

    Hello Nitesh,
    When we go through page life cycle Render events responsible for display the controls on browser. This event convert server side control into html control.This is event is also part of saving view state on page.
    if you want to deep knowledge of page life cycle then go through the author code url:

    http://www.authorcode.com/asp-net-page-life-cycle/

    Below is the code of render event that move the ViewState to the bottom of page.

    
    
    
     protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            System.IO.StringWriter stringWriter = new System.IO.StringWriter();
            HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
            base.Render(htmlWriter);
            string html = stringWriter.ToString();
            int StartPoint = html.IndexOf(" < input type=\"hidden\" name=\"__VIEWSTATE\"");
            if (StartPoint >= 0)
            {
                int EndPoint = html.IndexOf("/>", StartPoint) + 2;
                string viewstateInput = html.Substring(StartPoint, EndPoint - StartPoint);
                html = html.Remove(StartPoint, EndPoint - StartPoint);
                int FormEndStart = html.IndexOf("") - 1;
                if (FormEndStart >= 0)
                {
                    html = html.Insert(FormEndStart, viewstateInput);
                }
            }
            writer.Write(html);
    
        }
    
    
    
    
    in reply to: What is the difference between a.Equals(b) and a == b? #3336
    Pavan
    Member

    Hello Ankur,

    .Equals and == both used to compare.But internal working of both little bit different.
    .Equals work fine reference type and == work fine value type.
    Like if we string builder.The StringBuilder is reference type.

    StringBuilder a = new StringBuilder(“Pavan”);
    StringBuilder b= new StringBuilder(“Pavan”);

    a.Equals(b)–> return true
    a==b —> return false

    please let me know if you have any doubt.

    in reply to: What is the difference between a Thread and a Process? #3335
    Pavan
    Member

    Process: Is a collection of code,resource or virtual memory space.Process is a program in execution.Thread is subset of process.Each process have at-least have one Thread for execution of Process.Thread have separate path of execution.
    A process can have multiple threads. Thread is a Execution instruction. Threads cannot live without a process.
    there is two types thread 1: Foreground Thread 2: background Thread.
    I will post about thread type and thread containing methods in coming days on Author Code code.

    in reply to: What is the difference between an Assembly and a DLL? #3309
    Pavan
    Member

    1:Dll project independent.

    2:assembly is project specific.

    3:An assembly is a collection of one or more files and one of them DLL or EXE.

    4:DLL contains library code to be used by any program running on Windows. A DLL may contain either structured or object oriented libraries.

    5:A DLL file can have a nearly infinite possible entry points.

    6:Assembly present in bin can have either strong/weak Name and assembly in GAC Should have strong name.

    in reply to: What is the best use of the Using statement in .net #3210
    Pavan
    Member

    Hello MikeJ,
    Using in .Net is just like try catch and finally block. Like when we make connection with sql server then connection should be open in try block and we close the connection in finally block.
    But when we used using statement then no need to close the connection when connection object goes out of scope then it dispose connection automatically.
    Example 1:

    using(SqlConnection cn = new SqlConnection(ConfigurationManager.
    ConnectionStrings
    ["MyConnection"].ConnectionString))
    using(SqlCommand cmd = cn.CreateCommand())
    using(SqlDataAdapter sda = new SqlDataAdapter())
    { 
     cn.Open();
      /* code that actually does stuff */  
     }
    Example 2:
     Connection c;
    	try
    	{		c = new Connection(...);  	
                }
    	finally
    	{		c.Close();
    	}
    

    Thanks
    pavan

    in reply to: What is a dynamic assembly? #3156
    Pavan
    Member

    The System.Reflection.Emit namespace contains classes that allow a compiler or tool to emit metadata and Microsoft intermediate language (MSIL) and optionally generate a PE file on disk. The primary clients of these classes are script engines and compilers.

    Define lightweight global methods at run time, using the DynamicMethod class, and execute them using delegates.
    Define assemblies at run time and then run them and/or save them to disk.
    Define modules in new assemblies at run time and then run and/or save them to disk.
    Define types in modules at run time, create instances of these types, and invoke their methods.
    Define symbolic information for defined modules that can be used by tools such as debuggers and code profilers.

    in reply to: What is the .NET Framework? #3155
    Pavan
    Member

    Hello Ankur,
    can you tell me about the advantage of .net framework.

    Thanks
    pavan

    in reply to: save listview data to same excel file but different sheet #3154
    Pavan
    Member

    Hello All,
    I am looking for such type of code from last few days.but finally I found solution form authorcode. Thanks for providing solution.

    pavan

    in reply to: difference between abstract class and interface #3051
    Pavan
    Member

    Thank you shobhit It help me a lot.
    can you tell me how can i know in which condition we use Abstract Class and in which condition we use Interface.

    in reply to: Delete from Sql View #3050
    Pavan
    Member

    Hello Ankur,
    Thanks for your reply.
    We can’t delete records from view which is created by more than one table.its show you a error message like this :-

    Msg 4405, Level 16, State 1, Line 1
    View or function ‘multipletable’ is not updatable because the modification affects multiple base tables.

    in reply to: Delete from Sql View #3037
    Pavan
    Member

    Hello Ankur,
    i am trying to explain you delete operation on view by example.Like we have a table test have colums name(ID,NAME,SALARY) and now insert some test data into table.Now time to create view Test_view on table test.
    create view Test_view as select * from Test
    Now time to fire delete query on view.
    delete from Test_view where Id=”

    It’s time to check the records view and table both.then you will see the deleted record from view also deleted from table.

Viewing 15 posts - 1 through 15 (of 16 total)