Links
Calendar
<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567
Site statistics
Keywords
rezashirazi , posted on 15. November 2008, 13:46

You can create a function for removing html tags from html string. here it is:

    Protected Function removeHTML(ByVal html As String) As String
        If String.IsNullOrEmpty(html) Then
            Return ""
        Else
            Return System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", String.Empty)
        End If
    End Function

 Happy Programming Smile

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Very often we have a relative URL of some page or resource like "~/img/logo.gif" and we need an absolute URL
to insert it in some control or link (something like "http://www.rezashirazi.com/img/logo.gif")

Asp.Net 2.0 has some very useful methods that could help us to resolve the absolute URL we need.

First of them is Page method ResolveUrl() that converts a relative URL into one that is usable on the requesting client.
This means you we can pass to this method an URL that is relative to the current page, something like this:


        Page.ResolveUrl("img/logo.gif");
 

and it would return to us a valid relative URL , taking into account the current URL of the Page from where you are calling it.

Be the first to rate this post

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

If you use ASP.NET login control in your website, by default login session of your accounts expired after 20 minutes. For increasing session timeout there are some different methods but the simpleset methos is change your website configuration in web.config file. you have to add below data in your web.config file for this reason:

<sessionState mode ="InProc" timeout="540"/>

<httpRuntime executionTimeout="999999"/>

but If you are using Asp.net login control your session timeout problem exists after these changes. for increasing session timeout of asp.net login control change authentication tag in your web.config to below tag:

<authentication mode="Forms"> <forms timeout="540" slidingExpiration="true" loginUrl="~/Login.aspx" />

</authentication>

Your session expiration time is now 9 hours(540 minutes)! Smile

Be the first to rate this post

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

Hi All,

I did have an error like BC30456: 'Title' is not a member of 'ASP....

On my application the error was cause by the Inherits tag. Both of my child forms had the same Inherits "_Default". Then I changed one and it is ok now

Note: You have to change the Inherits tag in the .aspx and in the related .vb files because your inherits tag is repeated in other pages.

 Exemple .aspx :
<% @ Page Language ="VB" MasterPageFile="~/site.master" AutoEventWireup ="false" CodeFile="samplepage.aspx.vb" Inherits="_Default2" title="Sample Page" %>

Exemple .vb :
Partial Class _Default2 Inherits System.Web.UI.Page

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
<script runat="server">
    protected string now = DateTime.Now.ToString();
    public void Page_Load(object sender, EventArgs e)
    {
        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

System.Net.NetworkCredential cred = new System.Net.NetworkCredential("yourid@gmail.com", "yourpassword");

mail.To.Add("a@a.com");
mail.Subject = "subject goes here";

mail.From = new System.Net.Mail.MailAddress(yourid@gmail.com);
mail.IsBodyHtml = true;
mail.Body = "This message has been sent programmatically with GMail";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.Send(mail);
    }
</script>

Be the first to rate this post

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

Follow the steps below to change the default time session timeout in IIS.

1. Start Internet Information Services (IIS) administration tool (snap-in) from the Control Panel.
2. Navigate to the "Default Web Site" node, right click on it and then select "Properties".
3. In the 'Directory' tab click "Create" button, then click "OK".
4. Click on the "Home Directory" tab, then "Configuration".
5. Click on the "Options" tab.
6. Increase the "Session timeout" value and click "OK" twice until you return to the IIS snap-in.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
rezashirazi , posted on 19. October 2008, 10:11

You can increase your asp.net application session timeout in below methods:

 1) Include this in you web.config file:

<system.web>
        <sessionState timeout="540"/>

2) in the session_start of global.asax

protected void Session_Start(Object sender, EventArgs e)
{
Session.Timeout = 540;
}

The value of session timeout is in minutes.

 

Be the first to rate this post

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

You can use IsNull function for checking null values of columns, so your query does not return any NULL value in columns. for example see below query:

 SELECT ISNULL(<ColumnName>, '1900-01-01') from <TableName>

 

 

Currently rated 3.0 by 1 people

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

You can add userIsOnlineTimeWindow to your web.config file to specify calculate IsOnline time for users. like this:

<membership defaultProvider="CustomizedProvider" userIsOnlineTimeWindow="180">

 The UserIsOnlineTimeWindow property value is checked during the call to GetNumberOfUsersOnline. If the LastActivityDate for a user is greater than the current date and time minus the UserIsOnlineTimeWindow value in minutes, then the user is considered online. You can determine whether a membership user is considered online with the IsOnline property of the MembershipUser class.

The LastActivityDate for a user is updated when a user's credentials are successfully validated by the ValidateUser method. You can also update the LastActivityDate for a membership user when you call one of the GetUser overloads. If you call a GetUser overload that takes a userIsOnline parameter, specify a value of true to update the LastActivityDate for the user.

 Happy programming! Smile

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
rezashirazi , posted on 18. October 2008, 09:31

To show online users in your asp.net application (using asp.net membership provider) you can add below function to your code:

     Private Function GetAllUsersDataTable() As Data.DataView
        Dim dv As New Data.DataView

        Try
            Dim mc As MembershipUserCollection = Membership.GetAllUsers()

            Dim dt As New Data.DataTable("LastUsers")
            dt.Columns.Add("UserName", GetType(String))
            dt.Columns.Add("Ldate", GetType(DateTime))
            For Each st As MembershipUser In mc
                If st.IsOnline Then
                    dt.Rows.Add(New Object() {st.UserName, st.LastLoginDate})
                End If
            Next

            dt.AcceptChanges()
            dv.Table = dt

        Catch ex As Exception
        End Try

        Return dv
    End Function

This function gets online users and return them as a data view, then you can simply bind this data view to a gridview or repeater component in your page.

 Have a nice day!

Be the first to rate this post

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