Tuesday, January 27, 2009

VS.Net 2008 Tutorial and Training Kit

VS.Net 2008 Tutorial and .Net 3.5 Training Kit


This training kit includes

- Example usage of New Features of VS.Net 2008

- Introduction and Overview for LINQ, C# 3.0, WCF, WPF, Asp.net, Ajax, WF, VSTO, Silverlight, VB 9 and much more.

- Download Presentation, Hands-on Labs, and Demos for VS.Net 2008 Training Kit

Monday, January 19, 2009

VS.Net 2010 Videos and Features

VS.Net 2010 and .Net FX 4.0 Videos

VS.Net 2010 Features Overview
- Visual Studio 2010 Overview, Jason Zander
- Key Themes for Visual Studio 2010, Soma
- Lab Management in Visual Studio Team System 2010

Languages Day
- C# 4.0 Implementation and Design Questions, Anders Hejlsberg
- VB 10, Lucian Wischik- C++ 10: 10 is the new 6, Amit Mohindra

The IDE
- Being Code-Focused with Visual Studio 2010, Karen Liu
- Test-Driven Development and Visual Studio 2010, Karen Liu
- Future of Visual Studio Extensibility, Rico Mariani

Concurrency and Parallelism
- Parallel Extensions to the .NET Framework 4.0, Stephen Toub
- Parallel Patterns Library (Native Parallelism), Rick Molloy
- Parallel Debugging Tools in Visual Studio 2010, Daniel Moth

Web Tools
- Sharepoint Development with Visual Studio 2010, Reza Chitsaz
- Web Development and Deployment with Visual Studio 2010, Vishal Joshi

Onclick onserverclick htmlbutton problem and solution

Onclick onserverclick htmlbutton problem and solution

While creating controls dynamically in code html button can create a problem.

Example: Consider following code which i was trying to add to Table cell (Created runtime).


Table tblControls = new Table();
TableRow trControl1 = new TableRow();

TableCell tdControl1 = new TableCell();
tdControl1.Text = "<input id='Submit" + i + "' runat='server' type='button' value='Submit' onclick='alert('Yahooooo');' onserverclick='Submit_Click'></input>"

trControl1.Cells.Add(tdControl1);
tblControls.Rows.Add(trControl1);


In above code, onserverclick event was not working for me. Ideally it should work, but after googling, found that other developers are also facing same problem, the alternate work-around i come up with to deal this problem is create HtmlButton runtime its give you more control and flexibility.

List of added feature with solution are:
1. You can pass argument on button click.
2. Invoking Button Click event for specific runtime created control.
3. Better way to deal with client side code and server side code.


HtmlButton htmSubmit = new HtmlButton();
htmSubmit.ID = "Submit" + i.ToString();
htmSubmit.InnerHtml = "Submit";


//Adding client-side event

htmSubmit.Attributes.Add("onclick", "alert('Yahoooooo');");


//For Passing Argument to Button Click Event use Attributes.Add

htmSubmit.Attributes.Add("GuestId", "GuestUserId" + i.ToString());
htmSubmit.Attributes.Add("UserId", "UserId" + i.ToString());
htmSubmit.Attributes.Add("Message", strMessage);
htmSubmit.ServerClick += new System.EventHandler(this.Submit_Click);


//Finally your onseverclick event

protected void Submit_Click(object sender, EventArgs e)
{
HtmlButton btn = (HtmlButton)sender;
string strGuestUserId = btn.Attributes["GuestId"];
string strUserId = btn.Attributes["UserId"];
string strMessage = btn.Attributes["Message"];
Response.Write("Your have clicked " + btn.ID.ToString() + "<br/>" + strGuestUserId + "<br/>" + strUserId + "<br/>" +strMessage);
}

Wednesday, January 14, 2009

Multiple Querystring for Url Rewriting Asp.net

How to Handle Multiple Querystring for Url Rewriting in Asp.net


Please go through my earlier article on Url Rewriting.
@Update to my earlier article on Simplest Way to write Url Rewriting

If you have gone through my earlier article

<rewriter>
<rewrite url="~/Article/(.+)-(.+)-(.+).aspx" to="~/DynamicPage.aspx?MyTitleId=$2&amp;CategoryId=$3"/>
</rewriter>

In Web.Config file you can handle special character by replacing it with its code.
Example in our case we have replace & with &amp;

After making changes to web.config file you need to pass third argument as category Id, and that its.  Your code is ready to handle multiple querystring argument.

Sunday, January 11, 2009

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack


Cause of Error:
When we call Response.Redirect("") from try/catch block in asp.net, you will receive above error.

Example contains error:
   try
                    {
                        string strRedirectUrl = Session["ReturnUrl"].ToString();
                        Response.Redirect(strRedirectUrl);
                    }
                    catch(Exception ex)
                    {
                        Response.Redirect("Default.aspx");
                    }


Solution:
Make second argument of response.redirect("MyPage.aspx",false);
   
Example containing solution:
try
                    {
                        string strRedirectUrl = Session["ReturnUrl"].ToString();
                        Response.Redirect(strRedirectUrl,false);
                    }
                    catch(Exception ex)
                    {
                        Response.Redirect("Default.aspx");
                    }

Most Recent Post

Community Updates

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape