I have come across new functionality called "stringbuilder" in javascript using Ajax.
please follow the below steps to enable the Stringbuilder.
Step 1:
Add script manager tag in the aspx page.
Step 2:
Example:
<script type="text/javascript">
function buildAString(title)
{
var headTagStart = "";
var headTagEnd = "";
var titleTagStart = "";
var sb = new Sys.StringBuilder(this._headTagStart);
sb.append(titleTagEnd);
sb.append(title);
sb.append(titleTagEnd);
sb.append(headTagEnd);
// Displays: "The result: "
alert("The result" + sb.toString());
}
var title = "A Title";
buildAString(title);
</script>
Balas Blog..
I am Software Engineer working at Infinite Computer Solutions,I have initiated this blog for sharing knowledge in ASP,C#,ASP.NET,VB.NET,Javascript,Ajax,Linq,Silverlight,WCF,WPF,WWF,XML,Webservices,Sharepoint,Sqlserver 2000, Sqlserver 2005,XSL,Designpatterns,OOPS,OOAD,PL/SQL, Infragistics, Drag & Drop Framework,Infragistics 2009, ExtJS, Jquery,Nhibernate
Tuesday, November 24, 2009
Wednesday, November 11, 2009
Calling Parent Method from child control using Events & Delegates.
Before starting we should very clear about event and delegate
Event: it's handler which will call the delegate and it will call the method.
Delegate: it's a function pointer, it will point to the particular function.
Let me explain about calling parent method from the child control.
Step 1: create one aspx pages and usercontrol pages.
step 2:
In the usercontrol create one button and lable. The scenoria is like this when user click on the button has to call the child method as well as the parent method.
Step 3:
Create one user control with the following code.
Childcontrol.ascx
<asp:Button ID="btnShow" runat="server" />
<asp:Label ID="lblShow" runat="server"></asp:Label>
Childcontrol.ascx.cs
public delegate void callDelegate();
public event callDelegate callEvent;
protected void Page_Load(object sender, EventArgs e)
{
btnShow.Click += delegate
{
lblShow.Text = "Hi how are u";
this.showData();
};
}
protected virtual void showData()
{
if (this.callEvent != null)
{
this.callEvent();
}
}
Step 4:
Create one aspx page with name of Parent with the following code.
parent.aspx
<%@ Register Src="~/UserControl/Childuser.ascx" TagPrefix="child" TagName="UC" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblParent" runat="server"></asp:Label>
<child:UC id="UC1" runat="server"></child:UC>
</div>
</form>
</body>
</html>
parent.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
UC1.callEvent += new Childuser.callDelegate(UC1_callEvent);
}
void UC1_callEvent()
{
lblParent.Text = "Hi Parent";
}
Event: it's handler which will call the delegate and it will call the method.
Delegate: it's a function pointer, it will point to the particular function.
Let me explain about calling parent method from the child control.
Step 1: create one aspx pages and usercontrol pages.
step 2:
In the usercontrol create one button and lable. The scenoria is like this when user click on the button has to call the child method as well as the parent method.
Step 3:
Create one user control with the following code.
Childcontrol.ascx
<asp:Button ID="btnShow" runat="server" />
<asp:Label ID="lblShow" runat="server"></asp:Label>
Childcontrol.ascx.cs
public delegate void callDelegate();
public event callDelegate callEvent;
protected void Page_Load(object sender, EventArgs e)
{
btnShow.Click += delegate
{
lblShow.Text = "Hi how are u";
this.showData();
};
}
protected virtual void showData()
{
if (this.callEvent != null)
{
this.callEvent();
}
}
Step 4:
Create one aspx page with name of Parent with the following code.
parent.aspx
<%@ Register Src="~/UserControl/Childuser.ascx" TagPrefix="child" TagName="UC" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblParent" runat="server"></asp:Label>
<child:UC id="UC1" runat="server"></child:UC>
</div>
</form>
</body>
</html>
parent.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
UC1.callEvent += new Childuser.callDelegate(UC1_callEvent);
}
void UC1_callEvent()
{
lblParent.Text = "Hi Parent";
}
| Reactions: |
Monday, November 9, 2009
Base Pages using C#.Net
Now i am come with the scenario clearing the session on each page writing the code.
for clearing the session in common place.
we can use some thing called base pages. so that we can keep the code in seprate place.
Step 1:
Create one class file with the name of basepages.cs.
This will contain the one method which will clear the session objects permanently.
Example:
public class BasePages:System.Web.UI.Page
{
public void clearSession()
{ if (Page.User.Identity.IsAuthenticated == false)
{ Session.Abandon();
Response.Redirect("login.aspx");
}
}
}
step 2
Create one login with the extension of .Aspx page.in the code behind just inherit that base class method.
public partial class SessionCheck : Performance.BasePages
{
protected void Page_Load(object sender, EventArgs e)
{
base.clearSession();
}
}
for clearing the session in common place.
we can use some thing called base pages. so that we can keep the code in seprate place.
Step 1:
Create one class file with the name of basepages.cs.
This will contain the one method which will clear the session objects permanently.
Example:
public class BasePages:System.Web.UI.Page
{
public void clearSession()
{ if (Page.User.Identity.IsAuthenticated == false)
{ Session.Abandon();
Response.Redirect("login.aspx");
}
}
}
step 2
Create one login with the extension of .Aspx page.in the code behind just inherit that base class method.
public partial class SessionCheck : Performance.BasePages
{
protected void Page_Load(object sender, EventArgs e)
{
base.clearSession();
}
}
| Reactions: |
Thursday, November 5, 2009
Memory Profiler.
This is the tool which will find out memory leakage. using this we can fine tune the code.
download: http://memprofiler.com/
download: http://memprofiler.com/
| Reactions: |
Thursday, October 29, 2009
function overloading method in webservice.
It's not as direct like class overloding. In webservice we have to enable some settings for
enabling the function overloading. follow below steps.
1. Must Set Attributes of Web service. 2. Set binding ConformsTo = WSIProfile.None.
Sample Class with couple of overloaded methods which exposes as a webservice
Example:
Sample: using System;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/")]// set Binding information[WebServiceBinding(ConformsTo = WsiProfiles.None)] public class Service : System.Web.Services.WebService{ public Service () { //Uncomment the following line if using designed components //InitializeComponent(); }
// Set Message Name [WebMethod(MessageName="Add int Field")] public int Add(int a, int b) { return a + b; }
// Set Message Name [WebMethod(MessageName="Add float Field] public int Add(float a, float b) { return a + b; }}
enabling the function overloading. follow below steps.
1. Must Set Attributes of Web service. 2. Set binding ConformsTo = WSIProfile.None.
Sample Class with couple of overloaded methods which exposes as a webservice
Example:
Sample: using System;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/")]// set Binding information[WebServiceBinding(ConformsTo = WsiProfiles.None)] public class Service : System.Web.Services.WebService{ public Service () { //Uncomment the following line if using designed components //InitializeComponent(); }
// Set Message Name [WebMethod(MessageName="Add int Field")] public int Add(int a, int b) { return a + b; }
// Set Message Name [WebMethod(MessageName="Add float Field] public int Add(float a, float b) { return a + b; }}
| Reactions: |
Wednesday, October 28, 2009
Health monitoring
Health monitoring in the Web.config file.
This is nice feature in the dotnet frame work 3.5
it will automatically write the event log, When you will not handle the exception in the application,
<system.web>
<healthMonitoring enabled="true"></healthMonitoring>
</system.web>
This is nice feature in the dotnet frame work 3.5
it will automatically write the event log, When you will not handle the exception in the application,
<system.web>
<healthMonitoring enabled="true"></healthMonitoring>
</system.web>
| Reactions: |
Monday, October 26, 2009
Calling method from one user control from other usercontrol with out using property.
Take this scenorio, i have button and event in the first user control.
and i have label in the other usercontrol.
when i click on the button have to assign some value for label of other usercontrol with
out using the property
Step 1:
create first user control with following control and method.
<asp:Button ID="btnSubmit" onclick="btnSubmit_Click" runat="server" Text="Submit" />
public void btnSubmit_Click(object sender, EventArgs e)
{
test2 t2 = (test2)Page.FindControl("test2");
t2.callBTN(sender, e);
}
step 2:
create second user control with label with assigning value.
<asp:Label ID="lbltest" runat="server"></asp:Label>
public void callBTN(object sender, EventArgs e)
{
lbltest.Text = "DDDD";
}
and i have label in the other usercontrol.
when i click on the button have to assign some value for label of other usercontrol with
out using the property
Step 1:
create first user control with following control and method.
<asp:Button ID="btnSubmit" onclick="btnSubmit_Click" runat="server" Text="Submit" />
public void btnSubmit_Click(object sender, EventArgs e)
{
test2 t2 = (test2)Page.FindControl("test2");
t2.callBTN(sender, e);
}
step 2:
create second user control with label with assigning value.
<asp:Label ID="lbltest" runat="server"></asp:Label>
public void callBTN(object sender, EventArgs e)
{
lbltest.Text = "DDDD";
}
| Reactions: |
Enabling the zoom in and zoom out facility for image using Seadragon control in ajax.
I have come across new control in ajax zooming and zoom out for image. it's quite very
simple to implement this functionality.. it's nice feature thanks to Ajax team.
Step 1:
Create one xml file with the following attributes with tag. these are the attribute and tag will describe the functionality.
<Image TileSize="256" Overlap="1" Format="png" ServerFormat="Default">
<Size Width="1024" Height="768"/>
</Image>
Step 2:
create css class with image.
step 3:
<ajaxToolkit:Seadragon ID="Seadragon"
runat="server"
SourceUrl="sample.xml"> //Step1
CssClass="seadragon" //step 2
<ajaxToolkit:Seadragon>
simple to implement this functionality.. it's nice feature thanks to Ajax team.
Step 1:
Create one xml file with the following attributes with tag. these are the attribute and tag will describe the functionality.
<Image TileSize="256" Overlap="1" Format="png" ServerFormat="Default">
<Size Width="1024" Height="768"/>
</Image>
Step 2:
create css class with image.
step 3:
<ajaxToolkit:Seadragon ID="Seadragon"
runat="server"
SourceUrl="sample.xml"> //Step1
CssClass="seadragon" //step 2
<ajaxToolkit:Seadragon>
| Reactions: |
Subscribe to:
Posts (Atom)