Webpage does not show master page contents, Authentication=forms

Posted by Joggee | ASP.NET Tips, ASp.NET 2005, Web Config | Thursday 11 December 2008 6:21 pm

I was using form authentication in a web config and I have a Login.aspx page that I created based upon a “MasterPage.master” page.  Everything looks okay at design time but when I build the form and see in a broswer It was quit amazed that content of MasterPage were not displayed even no formatting, Even no  MasterPage.master or CSS were effecting.

I done configuration in a web config so If User start with “Default.aspx” It will be taken to the “Login.aspx” page because of below configuration settings.

    <authorization>
        <deny users=”?” />
    </authorization>
 
    <authentication mode=”Forms”>
      <forms loginUrl=”Login.aspx” path=”/” />
    </authentication>

I went into deep and come to know once you use authentication mode is equal to form, CSS or APP_THEME, or any content from master page are LOCKED.

You need to unlocked all the folder to get effect.

<location path=”Path of your CSS and Image file”  allowOverride=”true”> �
            <system.web>
                  <authorization>
                        <allow users=”*” />
                  </authorization>
            </system.web>
      </location>

Note : If you wanted to give more than one folder permission, you need to repeat the same code again and again.

Location tag should be placed properly otherwise It wont work.

Joggee.

Visual Studio 2010 and .NET Framework 4.0

Posted by Joggee | Downlaods, Installation, Tips and Tricks, Visual Studio 2010 | Friday 31 October 2008 7:00 am

Microsoft Unveils Next Version of Visual Studio and .NET Framework

Reveals extensive enhancements for simplified application life-cycle management, provides sneak peek at all key focus areas for Visual Studio 2010 and the .NET Framework 4.0.

The Visual Studio 2010 & .NET Framework 4.0 CTP is now available for Download. You can learn more about the CTP and engage with the product team directly to provide feedback here: http://go.microsoft.com/fwlink/?LinkId=129231

USEFUL LINKS

https://connect.microsoft.com/VisualStudio/Downloads
https://connect.microsoft.com/VisualStudio
http://www.microsoft.com/presspass/press/2008/sep08/09-29VS10PR.mspx
http://weblogs.asp.net/guybarrette/archive/2008/09/29/visual-studio-2010-first-previews.aspx

Joggee

 

SQL Server Truncate All Tables

Posted by Joggee | SQL Server 2005, SQL Tips and Tricks | Wednesday 17 September 2008 11:50 am

There was a scenario that I wanted to clear all the data from almost all tables, the first thing came into my mind.I created cursor which generate all the queries for me. I know this will be helpful for everybody.If you have any other solution please share with me.

DECLARE @TableName VARCHAR(256)
DECLARE @varSQL VARCHAR(512)

DECLARE @getTBName CURSOR SET @getTBName = CURSOR FOR SELECT name FROM sys.Tables WHERE NAME NOT LIKE ‘Category’

OPEN @getTBName FETCH NEXT FROM @getTBName INTO @TableName

WHILE @@FETCH_STATUS = 0
BEGIN
SET @varSQL = ‘Truncate table ‘+ @TableName + ”
– EXEC (@varSQL)
PRINT (@varSQL)
FETCH NEXT FROM @getTBName INTO @TableName

ENDCLOSE @getTBName
DEALLOCATE @getTBName

Joggee

How to change default browswer in ASP.NET?

Posted by Joggee | ASP.NET Tips, ASp.NET 2005 | Wednesday 20 August 2008 4:49 am

Its possible and simple, Why do we need to change the default browsewr, sometime when you install firefox or safari or any broswer it ask you to set as default browser which make setting for the complete system, then that becomes your default browser;to avoid this thing be sure when you are setting up or installing any new browser because that will prompt for making it as default.

Now If you would like to change your default broswer few steps and you will get your browser back.

You need to open your visual studio and on .aspx,html pages only.

Right click on a .aspx page/html in your solution explorer and select the “browse with” context menu option as shown below.

Browse With

 

In the dialog box you can select or add a browser.  If you want to add new broswer Safari in the list, click “add” and point to the safari.exe filename,Click the “Set as Default” button to make this the default browser when you run any page on the site.

Note that there is also an optional drop-down at the bottom of the dialog that lets you select the default browser window size when loading.  You can choose 800×600 or 1024×768 or any size which as per your resolutions settting.

Joggee

ASP.NET Useful Keyboard Commands

Posted by Joggee | ASP.NET Tips, ASp.NET 2005 | Thursday 3 July 2008 1:11 pm

Visual studio provide almost the same key combination what microsoft office has.

Some time we need to make all the text or Stored procedure texture in UPPER CASE for more readibility. Sometime in lower case. Visual studio does the same, but most of the developer use Microsoft word for this.

Here are the keys combination

Ctrl + Shift + U for “UPPER CASE”

Ctrl + U for “lower case”

How to create or add a Shortcut Icon to a Web Page,Logo with Address bar

Posted by Joggee | ASP.NET Books, ASp.NET 2005, Shortcut Icon | Monday 30 June 2008 11:03 am

What is shortcut Icon? As word specified shortcut ICON, Adding a website Logo as Icon to a Web page URL is called shortcut Icon. Any graphic can be display as logo to a windows Internet Explorer.

Shortcut icons are supported in Microsoft Internet Explorer 5 and later. Internet Explorer downloads a shortcut icon when a user first visits a Web page that has a valid icon.

For more clear concept It is highlighted in the below Image.

How to associate shortcut Icon with the webpage:
<
head>
<
LINK rel=”SHORTCUT ICON” href=”http://www.joggee.com/favicon.ico” type=”image/x-icon” />
</head>

Note:
In Internet Explorer 5 and 6, a shortcut icon does not display on the address bar unless the user chooses to add the page as a favorite.<script> <!– if ((navigator.appVersion.indexOf(”MSIE”) > 0) && (parseInt(navigator.appVersion) >= 4)) { var sText = “<u><span style=’color:blue;cursor:hand;’”; sText += “onclick=’window.external.AddFavorite(location.href,”; sText += “document.title);’>Add this page to your favorites</span></u>”; document.write(sText); } //–> </script> 

 

Useful link:
http://msdn.microsoft.com/en-us/library/ms537656(VS.85).aspx

Gates to leave day-to-day role at Microsoft

Posted by Joggee | Latest Hi-Tech Updates | Friday 27 June 2008 12:53 pm

http://www.nzherald.co.nz/multimedia/video.cfm?c_id=3&objectid=10518660&content_media_id=5008589

NEW YORK (CNNMoney.com) – Microsoft announced Thursday that chairman and co-founder Bill Gates will transition out of a day-to-day role at the company, effective July 2008, to spend more time working on his charitable foundation.

Gates will then work part-time at Microsoft (up $0.19 to $22.07, Charts) as chairman and technical adviser and will work full time for the Bill and Melinda Gates Foundation, the organization he founded with his wife, which focuses on global health and education.

Gates and Ballmer 

 

 Microsoft chairman and Chief Software Architect Bill Gates  

Microsoft Chairman Bill Gates announcing Thursday that he is stepping down from his day-to-day role with the company by July 2008.

 

“I’ve decided that two years from today, I will reorganize my personal priorities,” Gates said during a news conference, adding,”I have one of the best jobs in the world.”

“I believe with great wealth comes great responsibility – the responsibility to give back to society and make sure those resources are given back in the best possible way, to those in need,” he said. Gates added, “It’s not a retirement, it’s a reordering of my priorities.”

(Special Report: Goodbye, Mr. Gates, stories from CNNMoney,com, FORTUNE, FORTUNE Small Business, Business 2.0)


Why Gate looks so upset.
Bill Gates

Userful link:

http://www.betanews.com/article/Bill_Gates_to_Leave_Microsoft_in_2_Years/1150404593
http://www.nzherald.co.nz/section/3/story.cfm?c_id=3&objectid=10518660&ref=rss

Two Days Training Program on “Total Quality Management in Services Sector”

Posted by Joggee | Conference, NPO-Pakistan, Training | Friday 20 June 2008 5:29 am

National Productivity Organization (NPO), Ministry of Industries & Production in collaboration with Pakistan National Accreditation Council (PNAC), Ministry of Science & Technology, Australian Center for Education and Training (ACET) and Government Engineering Academy (GEA), Lahore is pleased to announce a two day training program on “Total Quality Management in the Services Sector” at Government Engineering Academy (GEA), Thokar Niaz Beg, Lahore from July 3-4, 2008.
You are kindly requested to disseminate this training program to your respective organizations and colleagues so that they can positively participate in the said program. For your reference, we are enclosing detailed brochure.
We look forward to your valuable cooperation and support in future.

Yours sincerely,
Zia ur Rehman
Management Associate
NPO-Pakistan

For more detail:
http://www.npo.gov.pk/NewsPages/TQM.pdf

Program list:
http://www.npo.gov.pk/events/programlist.asp

Usefull links:
http://www.npo.gov.pk/default.asp
http://www.npo.gov.pk/about.asp
http://www.npo.gov.pk/training/default.asp
http://www.npo.gov.pk/training/consultancy.asp
Download forms.
http://www.npo.gov.pk/rc/downloads.html 

URL Rewriting in ASP.NET with Sample Project

Posted by Joggee | ASP.NET Framework, ASP.NET Tips, ASp.NET 2005, Global.asax, URL Rewriting | Wednesday 11 June 2008 6:54 am

URL rewriting is the process of intercepting an incoming Web request and automatically redirecting it to a different URL.

To understand completely follow below link
http://msdn.microsoft.com/en-us/library/ms972974.aspx

In this article I am going make a simple example which will take only few minutes and you will learn how to achieve URL Rewriting.

I believe developer doesn’t have much time to read a complete article of 20 pages.

Here we go

Step 1
Create a table
(
POSTID INT
,
TITLE VARCHAR(255
),
BODY
TEXT
)

CREATE TABLE TESTTABLE

Insert some dummy values

INSERT INTO TESTTABLE (POSTID,TITLE,BODY) VALUES (1,‘ACCORDIAN CONTROL WITH SQL SERVER’,
‘ACCORDIAN CONTROL WITH SQL SERVER CONNECTIVITY JOGGEE
MADE A ARTICLE AND THAT IS THE BEST I THINK SO.’
)
GO
INSERT
INTO TESTTABLE (POSTID,TITLE,BODY) VALUES (2,‘Mouse over effect’
,
‘This is so simple and can found thousand places but I tried to make it more easier who
doesnt know the different between <asp:linked button> or anchor.’
)
GO

SELECT
* FROM
TESTTABLE

STEP – 2
Create a stored procedure
Create PROCEDURE PROC_TEST
AS

BEGIN
SELECT
‘<A HREF=Detail/’+REPLACE(TITLE,‘ ‘,‘_’) +‘~’ + CONVERT(VARCHAR,POSTID) + ‘.ASPX>’ + TITLE + ‘</A>’ AS ‘TITLE’
,
BODY
FROM
TESTTABLE
END

GO

Procedure for Detail Page.
CREATE PROCEDURE PROC_TESTDETAIL
@ID
INT
AS

BEGIN
SELECT
POSTID,
TITLE
,
BODY
FROM
TESTTABLE
WHERE POSTID =
@ID
END
GO

Database work is finished, let move to ASP.NET project means Website Programming.
Create a Website, Ajax Enabled or not its up to you, No matter what you choose.

In a default webpage write below code. I am pasting the complete code for Default page. where i am using DataList direct binding with two field. 

<@ Page Language=”VB” AutoEventWireup=”true” CodeFile=”Default.aspx.vb” Inherits=”_Default” %>

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<
html xmlns
=”http://www.w3.org/1999/xhtml”>
<
head runat
=”server”>
<
title>BLOG.JOGGEE</title
>
</
head
>
<
body
>
<
form id=”form1″ runat
=”server”>
<
asp:ScriptManager ID=”ScriptManager1″ runat
=”server” />
<
div
>
<
asp:DataList ID=”DataList1″ runat
=”server”>
<
ItemTemplate
>
<
table width
=”100%”>
<
tr
>
<
td><%# Container.DataItem(“Title”)%></td
>
</
tr
>
<
tr
>
<
td><%#Container.DataItem(“Body”)%></td
>
</
tr
>
</
table
>
</
ItemTemplate
>
</
asp:DataList></div
>
</
form
>
</
body
>
</
html>   

In a Code Behind Past below code.

Imports System.Data
Imports System.Data.SqlClientPartial Class _Default
Inherits System.Web.UI.PageProtected
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me

 

Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me

 

.Load
If IsPostBack = False
Then
Dim
sqlConn As New
SqlConnection
Dim sqlCmd As New SqlCommand(“PROC_TEST”
, sqlConn)
Dim objDA As New
SqlDataAdapter
Dim DT As New
DataTable
‘******************************************************************************************************
‘I have mentioned this connection string in the web.config Change it with appropriate values.
‘<add name=”connString” connectionString=”Data Source=”DATABASE SERVER NAME”;Initial Catalog=”DATABASE NAME”;User=”USER”;Password=”PASWORD”;”/>
‘****************************************************************************************************************
sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings(“connString”
).ConnectionString
‘opening a connection
sqlConn.Open()
sqlCmd.Connection = sqlConn
sqlCmd.CommandType = CommandType.StoredProcedure
objDA.SelectCommand = sqlCmd
‘populate data table
objDA.Fill(DT)
‘bind data
DataList1.DataSource = DT.DefaultView
DataList1.DataBind()
‘disposing all the declared objects.
objDA.Dispose()
objDA =
Nothing
sqlConn.Close()
sqlConn =
Nothing
sqlCmd.Dispose()
sqlCmd.Connection.Close()
sqlCmd =
Nothing
End
If
End
Sub
End
Class  

Code for Detail WebPage. 

Create a folder named “Detail” and add one more Default.aspx webpage. Please follow the instructions.

<% @ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” Inherits=”Detail_Default” %>

<! DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<
html xmlns=”http://www.w3.org/1999/xhtml”
>
<
head runat
=”server”>
<
title>Blog.Joggee</title
>
</
head
>
<
body
>
<
form id=”form1
runat=”server”>
<
div
>
<
asp:HyperLink ID=”HyperLink1
runat=”server” NavigateUrl=”~/Default.aspx”>Back</asp:HyperLink>
<
table width
=”100%”>
<
tr
>
<
td
>
Title
</
td
>
<
td
>
<
asp:Label ID=”lblTitle” runat=”server”></asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td style=”height: 191px” valign
=”top”>
Body:
</
td
>
<
td style
=”height: 191px”>
<
asp:TextBox ID=”txtBody” runat=”server” Height=”188px” TextMode=”MultiLine” Width=”975px”></asp:TextBox
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
form
>
</
body
>
</
html

In a Code Behind Just Copy Paste
Imports
System.Data
Imports System.Data.SqlClient 

Partial Class Detail_Default
Inherits System.Web.UI.Page

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then 

 Dim sqlConn As New SqlConnection

 Dim sqlCmd As New SqlCommand(“PROC_TESTDETAIL” , sqlConn)
Dim objDA As New SqlDataAdapter

 Dim DT As New DataTable

‘Here you can specify your connection string.

 sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings(

“connString” ).ConnectionString

‘opening a connection

sqlConn.Open()

sqlCmd.Connection = sqlConnsqlCmd.CommandType = CommandType.StoredProcedure

sqlCmd.Parameters.Add(“@ID”, SqlDbType.Int).Value = Request.QueryString(“ID” )
objDA.SelectCommand = sqlCmd

‘populate data table

objDA.Fill(DT)

‘bind data

lblTitle.Text = DT.Rows(0)(“Title”

txtBody.Text = DT.Rows(0)(“Body”

‘disposing all the declared objects.

objDA.Dispose()

objDA =Nothing

sqlConn.Close()

sqlConn =Nothing 

sqlCmd.Dispose()

sqlCmd.Connection.Close() 

sqlCmd =Nothing

End If
End Sub
End Class


Add Global.asax file in the project on the root

<%@ Application Language=”VB” %>

 

<script runat=”server”>

    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ‘ Code that runs on application startup
    End Sub
    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
        ‘ Code that runs on application shutdown
    End Sub
    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        ‘ Code that runs when an unhandled error occurs
    End Sub
    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ‘ Code that runs when a new session is started
    End Sub
    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        ‘ Code that runs when a session ends.
‘ Note: The Session_End event is raised only when the
‘ sessionstate mode
‘ is set to InProc in the Web.config file. If session
‘mode is set to StateServer�
 ‘ or SQLServer, the event is not raised.
    End Sub

 Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim Old As String
    Dim MovingPath As String
    Dim IncomingURL As HttpContext
    Dim StartingIndex As Integer
    Dim ID As String
IncomingURL = HttpContext.Current
Old = IncomingURL.Request.Path
‘here you can filtered with if condition if you don’t
 want any directory to be caught and redirected some where
  If Regex.IsMatch(Old, “/Detail/”) Then
      Old = Old.Replace(“.ASPX”, “”)
      StartingIndex = Old.IndexOf(“~”)
      ID = Old.Remove(0, StartingIndex + 1)
      MovingPath = “~/Detail/Default.aspx?id=” + ID.ToString
      IncomingURL.RewritePath(MovingPath)
  End If
End Sub
</script>

In a web.config Add this key

<connectionStrings>
<
add name=connString connectionString=Data Source=DATABASE SERVER NAME;Initial Catalog=DATABASE NAME;User=USER;Password=PASWORD;/>
</
connectionStrings>

Detail Page

.

 

 

 

 

CLICK HERE TO DOWNLOAD THE COMPLETE SAMPLE PROJECT

Joggee

Bill Gates’ last day at Microsoft (video)

Posted by Joggee | Funny | Friday 6 June 2008 8:08 am

A video spoof shown during the CES 2008 keynote by Bill Gates about his last full day at Microsoft in July starring himself, Brian Williams, Steve Ballmer, Matthew McConaugheyr, Robbie Bach, Jay-Z, Bono, Steven Spielberg, George Clooney, Jon Stewart, Kevin Turner, Hillary Clinton, Barack Obama, Al Gore, Ray Ozzie and Craig Mundie.

Can check out a wide screen version with high quality

http://www.istartedsomething.com/20080107/bill-gates-last-day-microsoft-video/

Next Page »