"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Thursday, May 13, 2010

FileUpload inside the Ajax UpdatePanel

Hi eveybody,
From my last projects i notice that file-upload not working with Ajax update panel.It showing me an error "Object reference is not an instance of object".So i make little study then i know that the file upload control  inside the update-panel and upload the file then FileUpload1.Hasfile is always false because file upload control is inside updatepanel then your file upload control does not post back. Because the file upload control works only when the full page postback. If you want to upload the file then you need to postback the page.


So we need to create the PostBackTrigger for the button.

We place <trigger> between <updatepanel> and <contenttemplate>

<asp:updatepanel id="UpdatePanel1" runat="server">
<contenttemplate>
<asp:fileupload id="FileUpload1" runat="server">
<asp:button id="btnSubmit" runat="server" text="Upload">
</asp:button>

</contenttemplate>
<triggers>
<asp:postbacktrigger controlid="btnSubmit">
</asp:postbacktrigger>
</triggers>

</updatepanel>
Triggers allow us to force a post back.


Have a nice day... 'N happy Coding :)
 Programming ASP.NET AJAX: Build rich, Web 2.0-style UI with ASP.NET AJAXProfessional ASP.NET 3.5 AJAX (Wrox Programmer to Programmer)Programming ASP.NET AJAX

Wednesday, May 12, 2010

Close window on button click in ASP.NET

 hi eveybody,
last i c on feed burner that on button clik they are closing the window(browser tab) that i opened.with the help of my friend i got that here it comes
On button click
  Response.Write("")
On the Page Load event
cancelButton.Attributes.Add("onclick", "window.close();")

 Have a nice day... 'N happy Coding :)
Firefox For DummiesDon't Click on the Blue E!: Switching to FirefoxProgramming Firefox

generate serial number for the rows in datagrid

To generate auto number for the rows in datagrid we can use the following code in ItemDataBound event.


private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
   if(e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
   {
     e.Item.Cells[0].Text=e.Item.ItemIndex.ToString();
   }
}


Have a nice day... 'N happy Coding :)
 Need For Speed CarbonNeed for Speed Carbon Collector's EditionNeed for Speed: Hot Pursuit 2