Denny.NET

I can haz ASP.NET goodness?

About the author

Denny Ferrassoli
Developer at Casting Networks. MCP / .NET
E-mail me Send mail
Add to Technorati Favorites

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Interview Questions: What Should I Expect?

I'm expecting an interview within the next few weeks for a position as a C# ASP.NET Developer (Mid-Level). At my current position I do a lot of VB.NET development; however I work with C# extensively at home on personal projects. I feel very confident about my presentation but in preparation would like to get some feedback on what to expect or what to focus on prior to an interview (C# specific). For example what kind of C# specific questions have you run into? What were you being tested for as far as your C# skills? Each company is different, of course, but I would like to hear about some of the experiences you have had.

I have read through Buu Nguyen's recent Interview Questions and this was a great starting point.

I look forward to your comments.

Update (4/30/2007 8:15am): Found a few more resources. This is a really good one http://www.devbistro.com/tech-interview-questions/.NET.jsp and also http://www.techinterviews.com/?cat=9

 

kick it on DotNetKicks.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: ASP.NET | Management
Posted by SuperGhost on Sunday, April 29, 2007 9:00 PM
Permalink | Comments (3) | Post RSSRSS comment feed

JavaScript and Server Controls

I've been finding quite a few people on the Client-Side forums on ASP.NET asking about how to bridge the gap between JavaScript and ASP.NET. The questions are usually related to getting data, or a variable, from JavaScript to ASP.NET and vice versa. So today I am going to show how to accomplish both tasks, along with some time saving tips. Ok, you know how I roll, let's get started.

Objective #1: Read and Set data to a TextBox Server Control from a JavaScript var

The only two things we'll need here is a TextBox Server Control and an Input button.

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button1" type="submit" value="JavaScript" onclick="return myScript();"/>

Notice the onclick event of the input button. It's pointing to the myScript() JavaScript function that we have yet to create. Let's do it now.

function myScript()
{
  // Reference to our TextBox1 Server Control
  var txtBox = document.getElementById("<%=TextBox1.ClientID%>");

  // Set
  txtBox.value ="You ran myScript()";

  // Read
  var read = txtBox.value;

  return false;
}

Pay very close attention to the "var txtBox" line. Look at the ID of the element. Now before we go on let me explain why I used <%=TextBox1.ClientID%> instead of the ID TextBox1. For .NET to keep track of all its server controls it generates IDs for each server control based on its heirarchy in the page. If you're looking at this page generated with a MasterPage you would get a different ID for the TextBox. Move the control into a Wizard and you'll get another ID.

Example: The same TextBox control inside a Wizard control looks like

<input name="Wizard1$TextBox1" type="text" id="Wizard1_TextBox1"/>

Notice the ID is now Wizard1_TextBox1. The JavaScript code would throw an error if it were looking for the ID TextBox1 because the .NET engine has rendered the control with a different ID. That's where ClientID comes in. ClientID contains the rendered ID of the server control. So no matter where you move TextBox1 on the page using TextBox1.ClientID will point to the correct element in HTML, and this is precisely what our JavaScript needs. This also saves you a lot of time should you ever want to move your controls around.

Side Note: The ClientID property should be used on Server Controls that implement the INamingContainer. This is to keep all control IDs unique (more here: http://msdn2.microsoft.com/en-us/library/3hc29e2a.aspx).

Continuing on now... Our txtBox variable now points to our TextBox1 server control. We can then set or read the value of the textbox using the next lines of code.

// Set
txtBox.value = "You ran myScript()";

// Read
var read = txtBox.value;

Finally we return false instructing the onclick event to stop any further processing. This stops the button from doing a postback. On the other hand you could return true. In this case the JavaScript code will run and then the form will postback.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by SuperGhost on Tuesday, April 24, 2007 9:00 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Return only numbers from a string

Here is a function I created some time ago to strip everything but numbers out of a string. We used this to canonicalize SSN's. You could get the same results using a Regular Expression and its respective Replace method.

Function numbersOnly(ByVal text As String) As String
 Dim nums As New StringBuilder

 For Each n As Char In text
  If Char.IsNumber(n) Then
   nums.Append(n)
  End If
 Next

 Return nums.ToString()
End Function

Testing the function with: 0-123-456-789 will return: 0123456789.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: ASP.NET
Posted by SuperGhost on Sunday, April 22, 2007 9:00 PM
Permalink | Comments (0) | Post RSSRSS comment feed

New Blog Address!

Welcome to the new Denny.NET blog

Please update your links to the new URL: http://www.dennydotnet.com

I will be testing and tweaking the new blog over the next few days. Also, I will be importing the old posts so that they can be found here as well.

Thanks to .NET Slave for the great blog engine which can be found on CodePlex. Also www.dotnetblogengine.net (and .com) will be up in the near future.

if (this.isTest) {
  string x ="Passed";
}

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General
Posted by SuperGhost on Wednesday, April 18, 2007 9:00 PM
Permalink | Comments (1) | Post RSSRSS comment feed