We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Tuesday, March 24, 2015

Interview Questions and Answers of ASP .NET



1. How To Dynamically Change Page Title?

To change page title with server-side ASP.NET code we can use Title property of Page object. Your code could look like this:
Page.Title = "This first Example";

Note that Title property doesn't exist in ASP.NET 1.1. If we work in ASP.NET 1.1 environment we can change page title if we add runat="server" attribute to tag. Use code like this:<br /> [ HTML ]<br /> <title id="PageTitle" runat="server">WebForm1
// We need this namespace to use HtmlGenericControl
using System.Web.UI.HtmlControls;

namespace FirstExam
{
public class WebForm1 : System.Web.UI.Page
{
// Variable declaration and instantiation
protected HtmlGenericControl PageTitle = new HtmlGenericControl();

private void Page_Load(object sender, System.EventArgs e)
{
// Set new page title
PageTitle.InnerText = "This first Example";
}

}
}

2. How To Check Is JavaScript Enabled

3.How To Find Out If Browser Supports JavaScript?

4. How To Create ASP.NET Website for Mobile Devices?

5.How To Read Connection String From Web.Config File?

6. How To Find Which Version of .NET Framework Is Used?

7. Can I Pass QueryString Variable From Classic ASP To ASP.NET?

8.How To Provide User Friendly 404 Pages?

9. How To Read Key/Value Pairs From AppSettings?

10. How To Read And Write A Cookie In ASP.NET

11.How To Find Referrer URL in ASP.NET?

12. How Much Is DataReader Faster Than DataSet?

13. How To Convert Text Box Value To Integer?

14. How To Allow Only Numbers In TextBox Control?

15. How To Close Browser Window With Button Click?

16. Should I Use RadioButtonList Or CheckBoxList Control?

17. How To Send Email With ASP.NET?

18. How To Make Directory In ASP.NET?

19. How To Get URL To Root Of Web Application?

20. How To Create Image Column In GridView?

21. How To Get List Of Folders?

22. How To Change Page Background Color With ASP.NET Server-Side

23. How To Write XML File From DataSet or DataTable?

24. How To Read Data From XML To DataSet And Show In GridView?

25. How To Delete A File In ASP.NET?

26.How To Fill DropDownList Control With ArrayList?

27. How To Post Back To Other Page With Button Control Click?

28. Can I Create First Letter As Drop Case By Using CSS Styles?

29. How To Link CSS file to ASP.NET page?

30. How To Get All Session Variables And Values?

31. How To Allow Only One Button Click In Long Time Operations?

32. How To Get Two Button's Click Execute The Same Function?

33. Can I Get Conditional RequiredFieldValidator On Client Side?

35. FileUpload Control Validation

37.How To Register Controls In Web.Config?

38. How To Read Web Page HTML Code With ASP.NET?

If data are not available in some kind of XML format (like RSS or web services), sometimes we need to deal with the HTML output of the web page. HTML is usually much harder to analyze than XML because you need to write our own parser which is different for every web site. But, the first step, reading of HTML output of the web page is pretty simple. To get HTML of the web page we need only a few lines of code.

To start, place two TextBox controls named txtURL and txtPageHTML, and one-button control on a web form, like in image below:

Webform for getting page HTML at design time

// We have to add namespaces
using System;
using System.Text;
using System.Net;

public partial class DefaultCS : System.Web.UI.Page
{

protected void btnGetHTML_Click(object sender, EventArgs e)
{
// We will use WebClient class for reading HTML of web page
WebClient MyWebClient = new WebClient();

// Read web page HTML to byte array
Byte[] PageHTMLBytes;
if (txtURL.Text != "")
{
PageHTMLBytes = MyWebClient.DownloadData(txtURL.Text);

// Convert this result from byte array to string
// and display it in TextBox txtPageHTML
UTF8Encoding oUTF8 = new UTF8Encoding();
txtPageHTML.Text = oUTF8.GetString(PageHTMLBytes);
}
}
}

Now we can have to start sample project, type some valid URL in first TextBox control and click to "btnGetHTML" button. Code listed above will return HTML code of requested URL and display it in the second text box, like in the image below:

HTML code is read and shown in the text box

As we see, the loading of the HTML code of the web page is relatively easy. Analyzing this data is much harder and depends on page structure.

39. How To Read File Information With ASP.NET?

40. How To Change Status Bar Text With ASP.NET?

41. How To Get Current URL?

Sometimes we need to find the current URL by using ASP.NET server-side code. That could be, for example, if we want to switch users from HTTP to HTTPS protocol we need to find current URL first and then redirect to URL with prefix https://.

To get the URL of the current page in ASP.NET you can use Request.Url.AbsoluteUri property, like in example code line below:

[ C# ]
string CurrentURL = Request.Url.AbsoluteUri;

42. Why DataList Control Is Not Visible On Page?

43. How To Read And Write Connection String In Web.Config?

44.Difference Between Image Class And Bitmap Class?

46. How To Create Thumbnail From Larger Image?

47. How to Find If User Is Logged In?

47. How to Logout User in ASP.NET Membership?

49. How To Change User's Email In ASP.NET Membership?

49. How to Load Text File To String?

No comments: