Set Default button in Asp.Net
Monday, October 5, 2009
HTML code
enter your table inside div tag and put onkeypress event in div tag
-----------------------------------------------------------------------------------------
<div id="pnlSearch" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'btnSearch')">
<table width="50%" cellpadding="0" cellspacing="0">
<tr>
<td>
Search :
</td>
<td>
<input name="txtSerach" type="text" id="txtSerach" />
</td>
<td colspan="2">
<input type="submit" name="btnSearch" value="Search" id="btnSearch" />
</td>
</tr>
</table>
</div>
------------------------------------------------------------------------------------------
Put this fuction inside script tag in your web page
------------------------------------------------------------------------------------------
function WebForm_FireDefaultButton(event, target) {
if (event.keyCode == 13) {
var src = event.srcElement || event.target;
if (!src || (src.tagName.toLowerCase() != "textarea")) {
var defaultButton;
if (__nonMSDOMBrowser) {
defaultButton = document.getElementById(target);
}
else {
defaultButton = document.all[target];
}
if (defaultButton && typeof(defaultButton.click) != "undefined") {
defaultButton.click();
event.cancelBubble = true;
if (event.stopPropagation) event.stopPropagation();
return false;
}
}
}
return true;
}
------------------------------------------------------------------------------------------
Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com
The base class includes the field 'headermain', but its type (Headermain) is not compatible with the type of control (ASP.include_headermain_ascx).
Wednesday, September 9, 2009
I am getting this error " The base class includes the field 'headermain', but its type (Headermain) is not compatible with the type of control (ASP.include_headermain_ascx). "
in line :
<TD vAlign="top" align="left" width="100%" colSpan="2"><uc1:headermain id="headermain" runat="server"></uc1:headermain ></TD>
Please find my code :
The name space ,i am using is this
<%@ Register TagPrefix="uc1" TagName="Leftmain" Src="include/Leftmain.ascx" %><%@ Register TagPrefix="uc1" TagName="Leftmain" Src="include/Leftmain.ascx" %> <%@ Register TagPrefix="uc1" TagName="Headermain" Src="include/Headermain.ascx" %>The code is
<TD vAlign="top" align="left" width="100%" colSpan="2"><uc1:headermain id="headermain" runat="server"></uc1:headermain></TD> <TD vAlign="top" align="left" width="200" height="100%"><uc1:leftmain id="leftmain" runat="server"></uc1:leftmain></TD> <TD vAlign="top" align="left" width="690" height="100%">
The Solution which i got has just solved my bugs,Please find my post on forums.asp.net at http://forums.asp.net/t/1468479.aspx
The solution i got is:<TR>
<TD vAlign="top" align="left" width="100%" colSpan="2"><uc1:headermain runat="server"></uc1:headermain></TD>
</TR>
<TR>
<TD vAlign="top" align="left" width="200" height="100%"><uc1:leftmain runat="server"></uc1:leftmain></TD>
<TD vAlign="top" align="left" width="690" height="100%">
//-----------------------------------------------------------------------------------------------
Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com
Page Authentication in C#
Friday, September 4, 2009
Hi friends,
Suppose if somebody browse some internal page of website, which require login authentication. Then mostly what happen is, the page is redirected to login page. After successfully login, user has to repeat whole cycle to reach that internal page; this is time consuming and frustrating for the visitor of the site.
The code, I am providing below, using that user don’t need to repeat whole cycle to reach that internal page, after login, User will be automatically redirected to that internal page of the website.
Code in C#:
If you are using Master page, then you should use this below code.
Put this below code in code behind of Master Page on Page_Load event
Explanation:
On login page, you might be creating Session for MemberId, suppose in below sample code, I have created Session [“AdminMemberID”] on login page on click event of submit button.
So I am just using that Session variable to compare for login authentication on master page. if user is not login and if you will try to open some internal page (Required Authentication) then below code will save that internal link in Session[“URL”] and redirect you to login page.
{
Session["URL"] = Request.Url.AbsoluteUri;
Response.Redirect("login.aspx");
}
[Note]: If you are not using master page then you need to keep above code to each .aspx page which requires user authentication.
Put below code on click event of Login button or submit button, which ever on your login page.
if (Session["URL"] == null)
{
Response.Redirect("Myaccount.aspx");
}
else
{
string URL = Convert.ToString(Session["URL"]);
Session.Remove("URL");
Response.Redirect(URL);
}
Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com
Clear your Visual Studio Recent projects list
Tuesday, September 1, 2009
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList
Rajesh Singh
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com
Clear your Visual Studio Recent projects list
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList
Rajesh Singh
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com








