Monday 25 April 2011

Retrieve data after hypen

Suppose you have a string separated by hypen("-").If you want only the portion which comes after hypen("-") then you have to write


public static String getID(String value)
{
          return value.Split('-')[value.Split('-').Length - 1].Trim();
}

Call button click event

In the checkchanged event of the checkbox  you can just call the
btnSave_Click event.

Ex:

private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
     btnSave_Click(sender, e);
}

or
btnSave_Click(null,null);
or
 ((IPostBackEventHandler)btnSave).RaisePostBackEvent(null);


If you want to call dropdown selected index changed method then do the following steps.


Ex:     Object sender=new Object();

      EventArgs myargs=new EventArgs();
      // Call the Drop down list Selected Index changed method
      ddlMyDropDown1_SelectedIndexChanged(sender, myargs);


Tuesday 19 April 2011

Important Site names

http://asp-net-example.blogspot.com/

http://www.learn-asp.net/ASPTutorials/SiteNavigation.aspx

http://technet.microsoft.com/en-us/library/cc917715.aspx

http://aspdotnet-suresh.blogspot.com/2011/03/how-to-selectdeselect-checkboxes-in.html

http://www.dotnetobject.com/showthread.php?tid=389&pid=776#pid776

http://aspdotnet-suresh.blogspot.com/2010/12/v-behaviorurldefaultvmlo.html

http://www.sqlusa.com/bestpractices2005/updatewithgroupby/

http://aspdotnet-suresh.blogspot.com/2010/12/how-to-show-limited-characters-in.html

http://aspdotnet-suresh.blogspot.com/2011/01/how-to-delete-records-in-gridview-with.html

http://shawpnendu.blogspot.com/2010/01/check-textarea-max-length-using.html

http://yasserzaid.wordpress.com/2011/04/

http://nice-tutorials.blogspot.com/2011/05/import-excel-data-to-gridview.html

http://www.c-sharpcorner.com/UploadFile/DipalChoksi/exportxl_asp2_dc11032006003657AM/exportxl_asp2_dc.aspx?ArticleID=000c64fb-8a22-414a-8247-984335aaa0eb

http://www.codeproject.com/KB/aspnet/sendemailxslt.aspx

http://www.devcurry.com/search/label/ASP.NET?updated-max=2011-01-22T02%3A55%3A00-08%3A00&max-results=20

http://dotnetslackers.com/articles/sql/Creating-Pivot-Table-and-Pivot-Chart-with-data-from-SQL-Server-2008.aspx

http://www.sqlservercentral.com/blogs/aloha_dba/archive/2010/03.aspx

http://csharpdotnetfreak.blogspot.com/2009/08/radiobuttonlist-dropdown-gridview-edit.html

http://www.ajaxtutorials.com/ajax-tutorials/?p=3

http://beyondrelational.com/blogs/jacob/archive/2009/01.aspx

http://mattberseth.com/blog/aspnet/

http://www.java2s.com/Tutorial/ASP.NET/CatalogASP.NET.htm

http://www.c-sharpcorner.com/UploadFile/navin.cp/N1006232008050100AM/N10.aspx (repeater with in griview)

http://weblogs.asp.net/dotnetstories/archive/2010/12/17/select-insert-update-and-delete-data-with-linq-to-sql-in-an-asp-net-application.aspx

Tuesday 5 April 2011

Repeater

Follow the below link to edit,update, delete record in repeater :

Monday 4 April 2011

Close window without the prompt message in IE7


If you tried to close a window using javascript window.close() method in IE7, and as you may noticed a message will prompt "The Webpage you are viewing is trying to close the window. Do you want to close this window".
Because of the security enhancements in IE7, you can't close a window unless it is opened by a script. so the walkaround will be to let the browser thinks that this page is opened using a script then closing the window. below is the implementation.
1- Create a javascript function which will be called to close the window
<script language="javascript" type="text/javascript">
function CloseWindow()
{
window.open('','_self','');
window.close();
}
</script>

The code in bold is used to open a window in this case it's not defined into the current window. in this way, we let the browser thinks that the current window is opened using javascript, so when the window.close() is executed it will close it without the message being displayed.
Now you can try it by adding the below HTML code
<a href="" onclick="CloseWindow();">Testing Close Window</a>
Hope this post will help you.

Restart ASP.NET Application Programatically

You can use the  HttpRuntime.UnloadAppDomain() which will terminate the application and of course remove all the session objects for all users the next time a request is being received.

Demonstration:
Create a dummy web application, drag and drop two buttons. and use some like below

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
       Session.Add("ASP","hello");
}
private void Button1_Click(object sender, System.EventArgs e)
{
        Response.Write(Session["ASP"].ToString());
        HttpRuntime.UnloadAppDomain();
}
private void Button2_Click(object sender, System.EventArgs e)
{
        Response.Write(Session["ASP"].ToString());
}


When you click Button2, you will have object reference not set to an instance of an object error which indicates that Session["ASP"] is equal to null.