Internet Explorer (IE) starts giving Javascript error when I tried to open Pop-up Dialog, Which works perfect with Fire Fox and Chrome.
You will find discussion topics for ASP.net, C#, JQuery, AJAX, SQL, VB.net, .Net Framework, WCF, WPF, WWF, WSS 3.0, MOSS 2007, OOPs Concepts, SQL Server, Programming.
Internet Explorer (IE) starts giving Javascript error when I tried to open Pop-up Dialog, Which works perfect with Fire Fox and Chrome.
Update to my previous post Rating Control Ajax - Display Message on Rating
Ajax Rating Control has bug, that is whenever user clicks the rating control, page causes jumps to top of the page. To avoid jump to top of page when user clicks Rating Control you need to add following line.
Add following line to maintain scroll position of page after user clicks rating control asp.net ajax.
protected void Page_Load(object sender, EventArgs e)
{
Rating1.Attributes.Add("onclick", "return false;");
}
For Detailed explanation about why Rating control jumps to top of page when user clicks on Rating control
Good Link for XSLT Transformation
XSL Transformation
Reflection is way through which we can identify metadata about assembly runtime.
Example: We have a .Net Assembly file (.dll file), which consist of 2 Class Definition and 10 Method Names, We can get information about classes and method name list through reflection.
Few Examples of Reflection
Loading Assembly FileAssembly assem = Assembly.LoadFrom(sAssemblyFileName);
Get List of Class Name.
Type[] types = assem.GetTypes();
Get List of Method Name
foreach (Type cls in types)
{
try
{
//Add Namespace Name
arrl.Add(cls.FullName);
//Add Class Name
if(cls.IsAbstract)
arrl.Add("Abstract Class:" + cls.Name.ToString());
else if(cls.IsPublic)
arrl.Add("Public Class:" + cls.Name.ToString());
else if(cls.IsSealed)
arrl.Add("Sealed Class:" + cls.Name.ToString());
MemberInfo[] methodName = cls.GetMethods();
foreach (MemberInfo method in methodName)
{
if (method.ReflectedType.IsPublic)
arrl.Add("\tPublic - " + method.Name.ToString());
else
arrl.Add("\tNon-Public - " + method.Name.ToString());
}
}
catch (System.NullReferenceException)
{
Console.WriteLine("Error msg");
}
}
private void btnListMethodName_Click(object sender, EventArgs e)
{
string sAssemblyFileName = txtAssemblyFileName.Text;
if (sAssemblyFileName.Length != 0)
{
Assembly assem = Assembly.LoadFrom(sAssemblyFileName);
Type[] types = assem.GetTypes();
ArrayList arrl = new ArrayList();
foreach (Type cls in types)
{
try
{
//Add Class Name
arrl.Add(cls.FullName);
if(cls.IsAbstract)
arrl.Add("Abstract Class:" + cls.Name.ToString());
else if(cls.IsPublic)
arrl.Add("Public Class:" + cls.Name.ToString());
else if(cls.IsSealed)
arrl.Add("Sealed Class:" + cls.Name.ToString());
MemberInfo[] methodName = cls.GetMethods();
foreach (MemberInfo method in methodName)
{
//arrl.Add("\t" + method.Name.ToString());
if (method.ReflectedType.IsPublic)
arrl.Add("\tPublic - " + method.Name.ToString());
else
arrl.Add("\tNon-Public - " + method.Name.ToString());
}
}
catch (System.NullReferenceException)
{
Console.WriteLine("Error msg");
}
}
//Dump Data to NotePad File
FileStream fs = new FileStream(@"c:\myData.txt", FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs);
for (int i = 0; i < arrl.Count; i++)
{
lstInfo.Items.Add(arrl[i].ToString());
sw.WriteLine(arrl[i].ToString());
}
sw.Flush();
sw.Close();
}
}
One Famous Problem with Rating Control is How to Display Message after Rating is done, without making use of button click.
Following Images Explain How can we display label text on Rating Control Click, without explicitly clicking any button control.
Before Rating Control is Clicked
During Rating Control is Clicked
After Rating Control is Clicked
Now, lets understand how to display message on click of Star Image.
Step1: Declare CSS Styles in Style Sheet file Also Add Images to Image Folder
.ratingStar {
font-size: 0pt;
width: 31px;
height: 30px;
margin: 0px;
padding: 0px;
cursor: pointer;
display: block;
background-repeat: no-repeat;
}
.filledRatingStar {
background-image: url(Images/FilledStar.png);
}
.emptyRatingStar {
background-image: url(Images/EmptyStar.png);
}
.savedRatingStar {
background-image: url(Images/SavedStar.png);
}
Step2: Declare ScriptManager in .aspx file with EnablePartialRendering=true
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
Step3: Declare UpdatePannel
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<!-- Declare Rating Control Here -->
</ContentTemplate>
</asp:UpdatePanel>
Step4: Add Rating Control and Label in UpdatePannel
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<!-- Rating Control -->
<cc1:Rating ID="Rating1" runat="server"
BehaviorID="RatingBhvrId1"
CurrentRating="3"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="Rating1_Changed"
ToolTip="Please Rate!"
style="float:left;">
</cc1:Rating>
<!-- Label to Display Message -->
<span id="lblResponse" class="heading"></span>
</ContentTemplate>
</asp:UpdatePanel>
Step5: Declare Necessary Javascript to show "Message" after user performs Rating with the help of e.CallbackResult
Step6: Declaring Rating1_Changed Event
<script language="javascript" type="text/javascript">
Sys.Application.add_load(function()
{
$find("RatingBhvrId1").add_EndClientCallback(function(sender, e)
{
var lblCtrl = document.getElementById('lblResponse');
lblCtrl.innerHTML = e.get_CallbackResult();
});
});
</script>protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
{
System.Threading.Thread.Sleep(500);
int iRate = Convert.ToInt16(e.Value);
string strMessage = string.Empty;
switch (iRate)
{
case 1:
strMessage = "Not Useful";
break;
case 2:
strMessage = "Average";
break;
case 3:
strMessage = "Useful";
break;
case 4:
strMessage = "Informative";
break;
case 5:
strMessage = "Excellent";
break;
}
strMessage = "Thanks for Rating, You found this Question " + strMessage;
e.CallbackResult = strMessage;
}
Summary View of .aspx Page
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:Rating ID="Rating1" runat="server"
BehaviorID="RatingBhvrId1"
CurrentRating="3"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="Rating1_Changed"
ToolTip="Please Rate!"
style="float:left;">
</cc1:Rating>
<br />
<span id="lblResponse" class="heading"></span>
<script language="javascript" type="text/javascript">
Sys.Application.add_load(function()
{
$find("RatingBhvrId1").add_EndClientCallback(function(sender, e)
{
var lblCtrl = document.getElementById('lblResponse');
lblCtrl.innerHTML = e.get_CallbackResult();
});
});
</script>
</ContentTemplate>
</asp:UpdatePanel>