Monday, 9 March 2015

save/upload files in folder and download files from folder in asp.net

Front end code:
<div>
<asp:FileUpload ID="fileUpload1" runat="server" /><br />
<asp:Button ID="btnUpload" runat="server" Text="Upload" onclick="btnUpload_Click" />
</div>

Back End Code:
protected void btnUpload_Click(object sender, EventArgs e)
{
string filename = Path.GetFileName(fileUpload1.PostedFile.FileName);
fileUpload1.SaveAs(Server.MapPath("Files/"+filename));
con.Open();
}

Sunday, 8 March 2015

How to Generate Popup window on method called or button click

In this I am explaining how to display Message Boxes in ASP.Net using JavaScript. ASP.Net. With the use of JavaScript alert we can display messages on different events in an ASP.Net Web Application.

C# code is given Below....
protected void Page_Load(object sender, EventArgs e)
{
  string message = "Hello! Mudassar.";
  System.Text.StringBuilder sb = new System.Text.StringBuilder();
  sb.Append("<script type = 'text/javascript'>");
  sb.Append("window.onload=function(){");
  sb.Append("alert('");
  sb.Append(message);
  sb.Append("')};");
  sb.Append("</script>");
  ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
}

ScreenShots:



Wednesday, 4 March 2015

New Ways To Interact With Your Computer - CES 2015 GetConnected TV

HP shows you some new technology that allows you to interact with your computer in ways not seen before. Join Andy Baryer at the CES 2015 ShowStoppers convention as he chats with HP about their new tech and HP Sprout.

The Future of Touch screen Technology 2015

This is the result of TAT's Open Innovation experiment. It is an experience video showing the future of screen technology with stretchable screens, transparent screens and e-ink displays, to name a few. I think this is pretty cool and shows the true capability of screen technology.

5 Mind Blowing Facts About Your Smartphone!

Today's smartphones are not what they used to be even just a few years ago. Smartphones are the fastest growing industry in history but that's not all.. Watch and learn these amazing facts about the devices in your pocket!

10 must have smartphones coming in 2015

As 2015 approaches,the next generation of smartphones are beginning to emerge. What will be the 10 must have smartphones of 2015?

computer Latest technology 2015

computer Latest technology 2015 Which All Based On touch and Pam Computers

Allie 720 Degree Interactive Video

IC Realtech demos their Allie cameras and software at CES Unveiled 2015.

Dying Light Using Oculus VR

Kyle Russell got an early look at first-person zombie-survival game Dying Light, which arrives on PC and consoles in January. This wasn’t your run-of-the-mill demo, however — Techland, the studio behind the game, let me play on an Oculus Rift connected to a maxed out gaming rig.

Google's DIY virtual reality cardboard headset - BBC News


Tuesday, 24 February 2015

How to change the text box date to dd/mm/yyyy format using c#


I want date in a dd/mm/yyyy format with validation in TextBox .

As I got date with dd/mm/yyyy but it will also accept 32/02/2005. Though Feb has less 30 days.


Also when I compare two textbox it will not evalute properly. eg I want TextBox2 date greater then TextBox1. So I had used
CompareValidator, & select type="date" but it will not evalute.


  1.  // .cs code.....
  2. private void DateSubmit_Click(object sender, System.EventArgs e)
  3. {
  4. DateTime date1, date2;
  5. bool date1OK, date2OK;
  6. date1 = new DateTime(1,1,1);
  7. date2 = new DateTime(1,1,1);
  8. try
  9. {
  10. date1 = Convert.ToDateTime(Date1.Text);
  11. date1OK=true;
  12. }
  13. catch
  14. {
  15. date1OK = false;
  16. }
  17. try
  18. {
  19. date2 = Convert.ToDateTime(Date2.Text);
  20. date2OK=true;
  21. }
  22. catch
  23. {
  24. date2OK = false;
  25. }
  26. if(date1OK && date2OK)
  27. {
  28. if(date1.CompareTo(date2) > -1)
  29. lblResult.Text = "Date2 must be after Date1";
  30. else
  31. {
  32. //do whatever here
  33. }
  34. }
  35. else lblResult.Text = "Invalid date format. Please check your input in the Date1 and Date2 fields";
  36. }

Friday, 13 February 2015

Cookie Management in ASP.NET


Cookie Management 

  • A set of Cookies is a small text file that is stored in the user's hard drive using the client's browser.
  •  Cookies are just used for the sake of the user's identity matching as it only stores information such as sessions id's, some frequent navigation or post-back request objects.
  • Whenever we get connected to the internet for accessing a specific service, the cookie file is accessed from our hard drive via our browser for identifying the user.
  •  The cookie access depends upon the life cycle or expiration of that specific cookie file.

Data is always stored as name-value pairs

To read a cookie you use the Request.Cookies method. You must always ensure that the cookie is not null before you use it.
Point 1: Write into a cookie collection:
Response.Cookies.Add(new HttpCookie(“cookiedata”, “This is some data stored in the cookie”));
Point 2: Reading cookie data
String readdata;
If(Request.Cookie[“cookiedata”] != null)
{
Readdata=Server.HtmlEncode(Request.Cookie[“cookiedata”].Value);
}
You can also set an expiration for the cookie using the Expires property.
Point 3: Setting cookie expiry
Response.Cookies[“cookiedata”].Expires=DateTime.Now.AddDays(1);
Here the cookie is allowed to expire after a day.
You can also control the scope of your cookie so that applications or pages outside the scope do not have access to your cookie.
Point 4: Setting cookie scope
Response.Cookies[“cookiedata”].Path=”/MyApp”;
Here the scope of the cookie is set to a “MyApp” virtual directory. Pages outside of this cannot access the cookie.
You can also to set the cookie scope to a domain.
Point 5: Setting a domain as cookie scope
Response.Cookies[“cookiedata”].Domain=”remalamanoj.com”;
You can also store multiple values in a cookie. Multiple values are stored as multiple key-values in a single cookie.
Point 6: Cookies with multiple values
Response.Cookies[“cookiedata”][“name”]=”Mr.MANOJ”;
Response.Cookies[“cookiedata”][“lastvisit”]=DateTime.Now;


Points to Remember Some features of cookies are:
  • Store information temporarily
  • It's just a simple small sized text file
  • Can be changed depending on requirements
  • User Preferred
  • Requires only a few bytes or KBs of space for creating cookies

Hidden Field Management in ASP.NET

Hidden Field Management 

  • A hidden field is used for storing small amounts of data on the client side. In most simple words it's just a container of some objects but their result is not rendered on our web browser. It is invisible in the browser. 
  • It stores a value for the single variable and it is the preferable way when a variable's value is changed frequently but we don't need to keep track of that every time in our application or web program.
  • Hidden field are the controls provided by the ASP.NET and they let use store some information in them. 
  • The only constraint on hidden filed is that it will keep the information when HTTP post is being done, i.e., button clicks. It will not work with HTTP get.


EXAMPLE: 
1.     // Hidden Field  
2.       
3.     int newVal = Convert.ToInt32(HiddenField1.Value) + 1;  
4.     HiddenField1.Value = newVal.ToString();  
5.     Label2.Text = HiddenField1.Value; 

Points to Remember:
      Some features of hidden fields are:
  • Contains a small amount of memory
  • Direct functionality access

what is ment View state Management in ASP.NET?

View state (client side state management in ASP.NET)

  • View state is a mechanism by which ASP.Net stores user-specific request and response data between requests. View state is not stored on the server, but is stored in the page itself. 
  • When the page is submitted to the server the view state is also submitted to the server. The web server pulls the view state from the page to reset the property values and controls when the page is being processed. 
  • This allows ASP.Net to have all the object data available to the web server without having to store it on the server. This results in a scalable web server which can handle more user requests.



  • Imagine a scenario where a user can edit some profile information. When processing the request the page might have to get information from the database.
  • In this case the data in various controls and the property values are stored in the view state. Suppose there is a problem with the submitted data and the page is returned back to the browser.
  •  You can see that the controls are populated with the data you entered and the property values are preserved. This is because the data is wrapped up into view state with your request and ASP.Net client-side state management features takes care of all this work for you.
  • Unless disabled, view state is a part of every ASP.Net page. The view state values are hashed, compressed and encoded for Unicode implementations which provide better optimization and security than simple hidden fields.

1: Example of view state
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NDU2MTA1MmRkqIBFV24wUH0Ny5RdjT5FltHvW5EIx6oxq6sSsk4aVOk=" />
View state is available as a
hidden field as shown above. You can view source of any .Net page and you will
come across a hidden field as above.
 Writing data to view state
this.ViewState.Add(“customdata”,”I am storing some data in view state”);
Reading view state data
string customdata=(string)ViewState[“customdata”];
  • Data is stored as objects in View state, so you should cast it to the correct data type before using it. You can store a wide variety of data in view state. 
  • Any object that is marked serializable can be added to view state.
  • Adding data to view state is great when you want to preserve information with page postback. However it does not transfer information from one page to another.
ADVANTAGE:

What is meant By State Management?? State management in ASP.NET

  • HTTP is a stateless protocol. Once the server serves any request from the user, it cleans up all the resources used to serve that request. These resources include the objects created during that request, the memory allocated during that request, etc.
  •  For a guy coming from a background of Windows application development, this could come as a big surprise because there is no way he could rely on objects and member variables alone to keep track of the current state of the application.
  • If we have to track the users' information between page visits and even on multiple visits of the same page, then we need to use the State management techniques provided by ASP.NET.


  •  State management is the process by which ASP.NET let the developers maintain state and page information over multiple request for the same or different pages.
Types of State Management

          There are mainly two types of state management that ASP.NET provides:
                            1. Client side state management
                            2. Server side state management.

             1. Client side state management
a  1.       When we use client side state management, the state related information will be stored on client side. This information will travel back and forth with every request and response. This can be visualized as:



    2.Server side state management, in contrast to client side, keeps all the information in user memory. The downside of this is more memory usage on server and the benefit is that users' confidential and sensitive information is secure.
   

1. Client side state management techniques

·                  1. View State
·         2. Control State
·         3. Hidden fields
·         4. Cookies
·         5. Query Strings

2. Server side state management techniques

·            1. Application State
·         2. Session State








Sunday, 4 January 2015

Mobile Application

       A mobile application, most commonly referred to as an app, is a type of application software designed to run on a mobile device, such as a smartphone or tablet computer. Mobile applications frequently serve to provide users with similar services to those accessed on PCs. Apps are generally small, individual software units with limited function. 
           This use of software has been popularized by Apple Inc. and its App Store, which sells thousands of applications for the iPhone, iPad and iPod Touch.
  

              A mobile application also may be known as an app, Web app, online app, iPhone app or smartphone app. Mobile applications are a move away from the integrated software systems generally found on PCs.
       Instead, each app provides limited and isolated functionality such as a game, calculator or mobile Web browsing.Although applications may have avoided multitasking because of the limited hardware resources of the early mobile devices, their specificity is now part of their desirability because they allow consumers to hand-pick what their devices are able to do.
             The simplest mobile apps take PC-based applications and port them to a mobile device. As mobile apps become more robust, this technique is somewhat lacking. A more sophisticated approach involves developing specifically for the mobile environment, taking advantage of both its limitations and advantages.

              For example, apps that use location-based features are inherently built from the ground up with an eye to mobile given that you don't have the same concept of location on a PC.