Sep 19

Sometimes, you might have found some schema files which you wanted to manipulate in your code with .NET. Microsoft provides a sample XSD to C#/VB.NET converter as a download to do this task yourself. Please at the following details to download it and use it.

== FROM Microsoft ==

Overview

The Sample Code Generator (XSDObjectGen) tool takes an XSD schema as input and generates sample code showing how to mark up C# and VB.Net classes so that when serialized with the XML serializer, the resulting XML will be valid according to the original schema. This update fixes some documentation changes and corrects a problem where the wizard did not generate code in some environments.

Link: Download


Jun 08

The master page implementation outlined above has another consequence to watch for. Since the master page injects it’s controls and markup into the page’s Controls array, any relative URLs in the master page markup may break. The browser will request the web form, not the master page, so all of the URLs will be relative to the web form. When the web form and master page are in different directories, relative URLs may point to the wrong location. To help alleviate relative URL problems, ASP.NET will rebase relative URLs for server-side controls in a master page. Rebasing will build the correct URL to the resource.

Courtesy from : http://www.odetocode.com/Articles/419.aspx


May 25

One of the most common mistakes beginner ASP.NET developers make is to call MsgBox.Show from their ASP.NET server-side code. It is a mistake because this code runs server-side and will just display the message box on the server where it’s not going to be very useful. Well, in version 2.0, it will actually throw an exception.

Once the developers understand the disconnected way HTTP works, it becomes quite natural, but the need to trigger an alert box from the server-side remains.

That’s why I just published a new GotDotNet workspace that contains an Alert server control and a ConfirmButton server control that you can use both client-side and server-side. The controls should work fine in all browsers, but will look a little nicer in IE thanks to the (non-standard) modal dialog feature.

Here’s how you use the controls…

First, if you want to show an alert from server-side code, you’ve got to first declare the alert in your page’s markup (or new up a new Microsoft.Samples.Alert.Alert control and set its properties and subcontrols if you’re that sort of developer):

<ms:Alert ID=”ServerAlert” runat=”server” Buttons=”OK” Title=”Server Alert” OnChoice=”ServerAlertChoice”
 
Font-Names=”Arial” HorizontalAlign=”Center” Width=”350px” Height
=”100px”>
 
This is a rich alert box that was triggered by<br /><i>server-side code</i>.<br
/>
</ms:Alert>

And then simply call the Show() method on the Alert instance from server-side code:

ServerAlert.Show();

You can handle the user’s choice server-side by handling the OnChoice event and act accordingly:

public void ServerAlertChoice(object sender, AlertChoiceEventArgs e) {
  AlertResult.Text =
“You clicked “
+ e.Result.ToString();
  AlertResult.Visible =
true
;
}

You can also trigger the alert’s display client-side and handle its response client-side:

<ms:Alert ID=”ClientAlert” runat=”server” Buttons=”YesNoCancel” Title=”Client Alert”
  Font-Names=”Arial” HorizontalAlign=”Center” Width=”350px” Height
=”140px”>
  This is a rich alert box that was triggered by<br /><i>client-side code</i>.<br
/>
  The button will take the value that you chose.<br /><br
/>
</ms:Alert
>
<input type=”button” name=”ClientShowButton” value
=”Show alert without posting back”
 
onclick=”this.value=<%= ClientAlert.GetShowClientEvent() %>;” /><br />

Or any combination that’s useful for you.

You can also use the ConfirmButton as you would use a regular button (it derives from Button) to ask the user for confirmation before posting back to the server:

<ms:ConfirmButton ID=”Confirm” runat=”server” OnClick=”ConfirmClick”
 
Text=”Confirm Button” ConfirmText=”Are you sure you want to press this button?” />

And so that you can use such confirm buttons in a repeated control such as a GridView, instances of a repeated confirm button can reference a single alert to save HTML rendering and not repeat the alert text for each data row:

<asp:GridView AutoGenerateColumns=”False” DataSourceID=”Datasource1″
  
ID=”GridView1″ runat=”server” DataKeyNames=”ID”>
 
<SelectedRowStyle BackColor=”gray” />
 
<Columns>
   
<asp:BoundField DataField=”ID” HeaderText=”ID” InsertVisible=”False” ReadOnly=”True”
     
SortExpression=”ID” Visible=”False”/>
   
<asp:BoundField DataField=”Name” HeaderText=”Name” SortExpression=”Name”/>
   
<asp:BoundField DataField=”Alias” HeaderText=”Alias” SortExpression=”Alias”/>
   
<asp:TemplateField HeaderText=”Command”>
     
<ItemTemplate>
       
<ms:ConfirmButton ID=”Confirm” runat=”server”
         
Alert=”GridSelectConfirmAlert” CommandName=”select”
         
Text=”Select” /><br />
     
</ItemTemplate>
   
</asp:TemplateField>
 
</Columns>
</asp:GridView>

<ms:Alert ID=”GridSelectConfirmAlert” runat=”server” Buttons=”YesNo” Title=”Are you sure?”
 
Font-Names=”Arial” HorizontalAlign=”Center” Width=”320px” Height=”50px”>
 
Are you sure you want to select this row?
</ms:Alert>

Check out the Alert.aspx page for these examples in context.


May 22

//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress(”me@mycompany.com”);
mail.To.Add(”you@yourcompany.com”);

//set the content
mail.Subject = “This is an email”;
mail.Body = “this is a sample body”;

//send the message
SmtpClient smtp = new SmtpClient(”127.0.0.1″);
smtp.Send(mail);


May 22

oooooooooohoooo. I found this free control in this site to show a popup calendar which i can link it with a typical text box. http://www.gotdotnet.com/Community/UserSamples/Download.aspx?SampleGuid=FED8B3BE-67E2-4BFC-BE34-404799B17D77

Show a Popup Calendar, Disable Holidays and Weekends Selection, Select using ranges of days (Specific Date, Today or Another TextBox Field), Support Right-to-Left Document for next cultures: Arabic, Farsi, Urdu, Hebrew and Syriac. Use different formats like (dd-mm-yyyy, yyyy.mmmm.dd, mmm/dd/yyyy, etc.), Use CSS to change the appearance of the Calendar, Support Required Date, Run in (Opera 7.21+, Netscapte 7+, Mozilla 1.4+, Mozilla FirexFox And IE5.5+) and More…
These versions use external files to set the properties and add special days.
Include help file (Not completed yet, explain extenal files).
Versions: RJS.Web.WebControl.PopCalendar.dll(6.5), PopCalendar.js(3.2.9), PopCalendarFunctions.js(2.6.0).
This ZIP include files for support the new Framework 2.0 (Library2005 and PopCalendar2005 - RJS.PopCalendar 10.0 (8.1.0)(8.1.2)


May 20

I was trying to publish a new application over the internet with ASP.NET Forms authentication. I had the login page named as “Login.aspx”. I tested it on my local and it all worked fine. I was happy enough to leave it public and published that. Boy, i got this wierd error:

CS0030: Cannot convert type ‘ASP.login_aspx’ to ‘System.Web.UI.WebControls.Login’

I thought there could be something to my hosting provider. After half a day of worth, i found this article http://www.groupsrv.com/dotnet/about147910.html which gave me the solution. So, i guess i have to rename the page to something other than Login.aspx because it was naming the class with the same class name which ASP.NET uses internally.

Worth to find it !!!