Wednesday, May 30, 2007

DENGAARU MOLEY!!!!!!!!!!!!!!!!!!!!!!

Devaranegu heltini...., "Mungaaru Male" na naanu 3 saari nodidagalu intha olle remix aitade adondu dialogueu antha andkondirodirli, adra sulivu irlilla nanage. Aadre ,nenne taane idanna nodide kanri...., satttogo astu nagu bandbidtu. Probably, nandu gatti jeeva adakke saaililla, adu secondary.
Idanne blognalli haakona antha haakta idini...., nothing offending plzzzzzzz :)

"Nivu nan kaili keyskondilla antha nange bejarilla kanri. Nim Thika, Nim Thode, Nim Sonta, Nivu baggidaaga nodida aa moley saaku kanri. Adanne rewind maadi maadi jatka hodkondu nan life na thalli bidthini kanri. Adre ondu vishya thilkolri nimma aa nagna deha nenskondu naanu jatka hodkolvastu bere yaaru hodkolalla kanri. Nan thunne murdogli, kithkond kai ge barli, naan satthru jatka hodkolthane irthini kanri!!!! [:D] "

Monday, May 21, 2007

All about "HEALTH MONITORING" in asp.net 2.0

Check this......., vvvvvv important concept

http://msdn2.microsoft.com/en-us/library/ms998306.aspx
Adding popup calendars in a aspx page

here is a good sample to pop up a server calendar control rather than use any javascript calendar control
http://www.15seconds.com/issue/040315.htm

if you want to use javascript calendar.. than check out this cool skinned calendar (dhtml) which can be used...
http://www.dynarch.com/projects/calendar/

There is a Calendar control in AJAX tool kit, it is a perfect one.
How Do I: Configure the ASP.NET AJAX Calendar Control?
To change button text as "page loading" once button is clicked :)

Execute the below code in page_load event


_System.Text.StringBuilder sbValid = _new _System.Text.StringBuilder();
sbValid.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sbValid.Append("if (Page_ClientValidate() == false) { return false; }} ");
sbValid.Append("this.value = 'Please wait...';");
sbValid.Append("this.disabled = true;");
sbValid.Append("document.all.btnSubmit.disabled = true;");
//GetPostBackEventReference obtains a reference to a client-side script function that causes the server to post back to the page.
sbValid.Append(this.Page.GetPostBackEventReference(this.btnSubmit));
sbValid.Append(";");
_this.btnSubmit.Attributes.Add("onclick", sbValid.ToString());

Where btnSubmit is a simple asp button

I need to read Html source of a Web From at Server -- Copy the whole html source code before actually rendering it

<%@ _Page Language="C#" _AutoEventWireup="true" _CodeFile="RenderPageToHtml.aspx.cs" _Inherits="RenderPageToHtml" _Trace="true" %>

<_head runat="server"> <_title>Untitled Page<_body>

<_form id="form1" _runat="server"> <_div> <_asp:_textbox id="TextBox1" runat="server" height="414px" textmode="MultiLine" width="198px"> <_asp:_button id="Button1" runat="server" text="Button"> <_asp:_linkbutton id="LinkButton1" runat="server">LinkButton using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class RenderPageToHtml : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (Session["text"] != null) { TextBox1.Text = Session["text"].ToString(); } } protected override void Render(HtmlTextWriter writer) { System.IO.MemoryStream mem = new System.IO.MemoryStream(); System.IO.StreamWriter twr = new System.IO.StreamWriter(mem); System.Web.UI.HtmlTextWriter myWriter = new HtmlTextWriter(twr); base.Render(myWriter);
myWriter.Flush(); myWriter.Dispose();
System.IO.StreamReader strmRdr = new System.IO.StreamReader(mem); strmRdr.BaseStream.Position = 0; string pageContent = strmRdr.ReadToEnd(); strmRdr.Dispose(); mem.Dispose(); Session["text"] = pageContent; writer.Write(pageContent); }}

Reference: http://forums.asp.net/t/1112091.aspx

How to convert excel and csv file into xml in asp.net....

Hi,
To convert excel to XML see:
http://www.codeproject.com/office/excel2xml.asp
To convert CSV to XML see:
http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx
(It is not writed via ASP.NET, but you can refer it.)
To convert excel to csv see:
http://www.devasp.net/net/articles/display/141.html
Another way to insert data into database

string Name = _TextBox1.Text;
string Surname = _TextBox2.Text;
SqlDataSource userQuizDataSource = new SqlDataSource(); userQuizDataSource.ConnectionString =
ConfigurationManager.ConnectionStrings["Demo_DBConnection"].ToString(); userQuizDataSource.InsertCommand = "INSERT INTO [Student] ([Name], [Surname]) VALUES (@Name,@Surname)";

userQuizDataSource.InsertParameters.Add("Name", Name); userQuizDataSource.InsertParameters.Add("Surname", Surname); userQuizDataSource.Insert();
file upload options: http://msdn2.microsoft.com/en-us/library/aa478971.aspx
Disable Button On PostBack (ASP.NET) - also works with validation controls

http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx

Thursday, May 17, 2007

Binding Values to Grid View(Also to display serial numbers)

<_asp:gridview _id="GridTranSummary" _runat="server" _autogeneratecolumns="False">
<_columns>
<_asp:templatefield headertext = "Serial Number">
<_itemtemplate>
<_%#container.dataitemindex>
<_/itemtemplate>
<_/asp:templatefield>
<_asp:boundfield datafield = "PK_MASTER_TRANID" headertext = "Transaction ID">
<_asp:templatefield headertext = "Week Details">
<_itemtemplate>
<%#DataBinder.Eval((Container.DataItem),"ENDDA","{0:MM/dd/yyyy}")%><%#_DataBinder.Eval(Container.DataItem, "BEGDA", "{0:MM/dd/yyyy}")%><%#_DataBinder.Eval((Container.DataItem),"ENDDA","{0:MM/dd/yyyy}")%><_%#_databinder._eval(_container._dataitem,> - <_%#_databinder.eval((_container.dataitem),"endda","{0:mm/dd/yyyy}")%>
<_/itemtemplate>
<_/asp:templatefield>
<_asp:templatefield>
<_itemtemplate>
<_asp _commandname ="">


Wednesday, May 16, 2007

I've got a TextBox and a Button, I want when I press Enter within the TextBox, it will trigger the Button, after that, the Cursor, will go back to the TextBox.

1.You can add a Javascript function in your page, as shown below:
_function _doSubmit()
{
if_(event.keyCode==13)
_document.all.xxx.click();
}
2. And then add this : _onkeydown="_doSubmit();" in the onkeydown event of the target TextBox.
3. After that, in your code-behind page, set the cursor back to the TextBox by using the postback method in your PageLoad event. e.g. this.TextBox1.Focus();

Tuesday, May 15, 2007

Disable the use of back button on browser - the solution
http://forums.asp.net/thread/1555332.aspx
Adding elements to a Form in JavaScript

I came across this code (sorry dont remember the web site) that I have posted in
response to many of the posts related to this type of problem. I thought it would
be easier if I post this code here for others to find.
/// <_summary>
/// Finds a Control recursively. Note finds the first match that exists
///
/// <_param name="ContainerCtl">Should be the lowest container in the heirarchy,
for eg dont choose Master page if you can pick the specific panel
/// <_param name="IdToFind">ID of the control you are looking for
/// <_returns>the control if found else null
_private static Control _FindControlRecursive(Control Root, string Id)
{
if (Root.ID == Id)
return Root;
foreach (Control Ctl in Root.Controls)
{
Control FoundCtl = FindControlRecursive(Ctl, Id);
if (FoundCtl != null)
return FoundCtl;
}
return null;
}
All about settings in .net 2.0
http://www.microsoft.com/technet/technetmag/issues/2006/11/InsideMSCOM/
Enabling Remote Debugging in .net

To enable debugging @ server when there is a event triggered @ client side.ie, if there is break point placed at ne point in the server, once client requests for the page, and break point is reached, we can easily trace and debug the same @ server side.

In server place a break point whereever u wanna debug, and Debug -- >procesess
aspnet_wp.exe

select this and attach (check clr)
More Details: http://support.microsoft.com/kb/893657
javascript debugging in vs.net 2.0

enable debuggin in internet explorer. type debugger; in javascript in aspx page
Tools -- > Internet Options --> Advanced --> uncheck Disable Script debugging(IE) and others

Friday, May 11, 2007

Reset all the packages in both .net 1.1 and .net 2.0

Execute this in the .net command prompt and restart visual studio.
devenv /resetpkgs

Monday, May 07, 2007

Sending Mails using System.Net.Mail

XML Documentation helps in displaying the metadata for the dll users, so ne info thats required to be shared with DLL users can be commented here. Check "intMailFormat" parameter, users using this dll shud know wat exactly to be passed.
//----------------Use Full piece of code--------------------------------


/// <_summary>
/// Function overloaded without Attachments
///
/// <_param name="strTo">Receiver Mail ID
/// <_param name="strCC">Carbon Copy Receivers>
/// <_param name="strBCC">Blind Carbon Copy Receivers

/// <_param name="strFrom">Sender Mail ID
/// <_param name="strSubject">Mail Subject
/// <_param name="strBody">Mail Body
/// <_param name="intMailFormat">Mail Format expects 0 for Plain Text and 1 for HTML(HTML is the default)

#region Sending Mail without attachments
public static void sendMail(string strTo, string strCC, string strBCC, string strFrom, string strSubject, string strBody, int intMailFormat)
{
try
{
MailMessage MailMsg = new MailMessage();

MailMsg.From = new MailAddress(strFrom);
MailMsg.To.Add(strTo);
if (strCC.Trim() != "")
{
MailMsg.CC.Add(strCC);
}
if (strBCC.Trim() != "")
{
MailMsg.Bcc.Add(strBCC);
}
MailMsg.Subject = strSubject;
MailMsg.Body = strBody;
if (intMailFormat == 0)
{
MailMsg.IsBodyHtml = false;
}
else
{
MailMsg.IsBodyHtml = true;
}
SmtpClient client = new SmtpClient("localhost");
client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
client.UseDefaultCredentials = true;
client.Send(MailMsg);
}
catch (Exception ex)
{
throw ex;
}
}

#endregion
Check All and UnCheck All Functionality


function_ functionCheckUnCheck()
{
var flagCheckUnCheck;
var buttonValue;
if(document.getElementById("btnCheckUnCheck").value == "Check All")
{
flagCheckUnCheck = true;
buttonValue = "UnCheck All";
}
else if(document.getElementById("btnCheckUnCheck").value == "UnCheck All")
{
flagCheckUnCheck = false;
buttonValue = "Check All";
}
var theGridView = document.getElementById("grdvShortTermFTRs");
for ( var rowCount = 1; rowCount < checked =" flagCheckUnCheck;" value =" buttonValue;">

Button:

input_ type="button" id="btnCheckUnCheck" value="Check All" onclick="functionCheckUnCheck()"

Sunday, May 06, 2007

Solution for asp:button to return back on client validation being failure:

NOTE: JavaScript is case sensitive, so make sure same keywords are used.
return false; or event.returnValue=false;

Friday, May 04, 2007

Asp ImageButton/Button submits the page even though onClientClick javascript returns failure :(

Javascript function should actually make event.returnValue = false; and not return failure or -1
NOTE: Since this blog will not let me key in script tags, _ is prefixed ;)

While working an ASP.NET 2.0 project today I ran across a problem with the OnClientClick event within the Button WebControl. The problem is that .NET renders this button:

<_asp:button id="btnAddChoice" runat="server" text="Add" onclientclick="AddToListBox(lbxChoices, txtChoiceName);">
as
<_input type="submit" name="btnAddChoice" value="Add" onclick="AddToListBox(lbxChoices, txtChoiceName);">

So when I click on the button, my JavaScript fires correctly but the page then submits -not what I want it to do. Thinking fast, I added a snippet to return false after my client-script ran, like so:

<_input type="submit" name="btnAddChoice" value="Add" onclick="AddToListBox(lbxChoices, txtChoiceName);return false;">

This however, does not work; the page still submits. After looking at the rendered HTML I can see the problem right away -the button type is submit. What I need is for it to be a type of button. An input control of type button, will not automatically submit the form. But how do I get .NET to render one?What I do not want to to is capture it just before it renders and change it there. And I also do not want to try to manipulate the type attribute after it's already been rendered. The solution I found; .NET has a added an attribute (boolean) to the Button WebControl called UseSubmitBehavior. By setting it to false in the WebControl, like so:

<_asp:button id="btnAddChoice" runat="server" text="Add" onclientclick="AddToListBox(lbxChoices, txtChoiceName); return false;" usesubmitbehavior="false">

Renders the input control like I want it to, as a button:
<_input type="button" name="btnAddChoice" value="Add" onclick="AddToListBox(lbxChoices, txtChoiceName); return false;__doPostBack('btnAddChoice','')">
Notice that I still need to stop the execution of the JavaScript by returning false because .NET added __doPostBack('btnAddChoice','') to the onclick event. But the main difference is that by returning false the page DOES NOT submit. Now, I can go back to writing my client-script to manipulate the page and capture those changes when the real submit button is clicked and the server code takes over.

Reference: http://www.xerratus.com/CommentView,guid,5a3ee461-185b-4253-9f98-2a9254208b15.aspx#commentstart


Thursday, May 03, 2007

Print File without prompting the user

Dim MyProcess As New Process
MyProcess.StartInfo.CreateNoWindow = False
MyProcess.StartInfo.Verb = "print"
MyProcess.StartInfo.FileName = "C:\Test.pdf"
MyProcess.Start()
MyProcess.WaitForExit(10000)
MyProcess.CloseMainWindow()
MyProcess.Close()

To print all the files in the folder, just loop through all the files and pint them as above :)

reference: http://www.dnzone.com/forum/topic.asp?topic_id=89

Wednesday, May 02, 2007

ICallbackEventHandler vs AJAX.NET

There’s been much excitement recently about AJAX and how it provides a rich model for callbacks and client scripting. There’s also been much disappointment in the ASP.NET 2.0 callback implementation with ICallbackEventHandler, especially in contrast to what AJAX does.

As I see it, AJAX provides two things over and beyond ICallbackEventHandler. The first feature is arbitrary parameters to the target method. The implementation uses reflection to map the incoming call onto an arbitrary method and its parameters. This is certainly convenient. The second feature going for it is generating JavaScript objects in the client script that correspond to server side types returned from the callback method. This is also very convenient.

With those two slick features over ICallbackEventHandler, it’s easy to overlook what AJAX doesn’t do well. The primary thing that ICallbackEventHandler has over AJAX is that it integrates very well into the server page lifecycle. This might seem unnecessary and it is if all your callback method is executing code unrelated to the page object on the server (like accessing a database and returning some values, say). But, integrating into the page model is essential if you want to leverage all those server controls.

An interesting technique is to use Control.RenderControl in the callback method. This will ask the control to render itself into a buffer that you have manually constructed. The rendered HTML in the buffer will be the result of your call method. Then in the client there’s little work to do except to take the returned HTML and replace a tag’s innerHTML with those results. Although sorting is an option on the GridView, it works well as an example of this technique that can be used for almost any custom control:
This technique makes the page more efficient because we’ve eliminated the bloated ViewState for the GridView. We post to the server only what we need for it to do its job. And the returned data is just the piece of the page that needs updating. This certainly beats reposting the entire page.After I wrote up this sample, I started wondering how the GridView (and TreeView, for that matter) were implemented when you enable the EnableSortingAndPagingCallbacks property (or EnableClientScript for the TreeView). It turns out they do essentially the same thing. They call RenderControl on themselves and send that back to the client which is then simply replaced in the client DOM. This is definitely a useful technique.

reference : http://staff.develop.com/ballen/blog/PermaLink.aspx?guid=c35c43f6-5686-40ee-9752-8095a848d821
Is there a difference when defining it in <connectionstrings> or <appSettings>?

"In ASP.NET 2.0, features, such as Session, Membership, Personalization, and Role Manager, rely on connection strings that are stored in the connectionStrings element. You can also use the connectionStrings element to store connection strings for your own applications".
Yes, it says "can" use it. And when loooking at the code above - what have I gained? Nothing...The connectionstring I have added can't be used by GUI designtime controls - since it doesn't have a providername, secondly I don't like the separation of the connstring and the dataaccesscomponent elements.

Doesn't feel right. So, in other words - I put it all in appsettings - no change for me .

So while being my personal opinion, there are sure cases when connectionstrings in appsettings still are justified. However, for the most .NET:ed solution, one maybe should use some sort of provider system instead - define the connection in and then use the providermodel for the different types of databases and have the provider point to the connectionStrings.
Validating Grid View (Awesome Solution)

This function can be used to check for check box being checked in the itemtemplate of a grid view.
function selected()
{
var theGridView = document.getElementById("grdvLocationSpecific");

for ( var rowCount = 1; rowCount < theGridView.rows.length; rowCount++ )
{
if ( theGridView.rows(rowCount).cells(0).children(0)!=null)
{
if ( theGridView.rows(rowCount).cells(0).children(0).checked == true)
{
alert("Checked");

var bbolflag =false;
for(var child2count=0;child2count {
if ( theGridView.rows(rowCount).cells(1).children(0).children(child2count).selected == true)
{
bbolflag=true;
}
}
if(!bbolflag)
{
alert("Not Selected");
}

}
else
{
alert("UNchecked");
}
}
}
}

This function can be used to check for text box being checked in the itemtemplate of a grid view.

function selected123()
{
var theGridView = document.getElementById("grdvLocationSpecific");

for ( var rowCount = 1; rowCount < theGridView.rows.length; rowCount++ )
{
if ( theGridView.rows(rowCount).cells(0).children(0)!=null)
{
if ( theGridView.rows(rowCount).cells(0).children(0).checked == true)
{
alert("Checked");

if ( theGridView.rows(rowCount).cells(2).children(0).value != "")
{
alert("Entered");
}
else
{
alert("not entered");
}
}
else
{
alert("UNchecked");
}
}
}
}

Check out this post for more details:
http://forums.asp.net/2/1659719/ShowThread.aspx