Monday, September 28, 2009

Invalid win32

Got weird errors like: invalid win32 application.

This is due to the following scenario:

64Bit IIS7 running a 32Bit application so Enable 32Bit is set to true on the application pool
Also running as an exchange front end server and hence RPCProxy is loaded

In this scenario you might get the errors

In IE -
"HTTP Error 503. The service is unavailable."


In the event viewer-
"The Module DLL C:\Windows\system32\RpcProxy\RpcProxy.dll failed to load. The data is the error."
and
"Application pool 'xxxxxxxxx' is being automatically disabled due to a series of failures in the process(es) serving that application pool."

Essentially the rpcpoxy is trying to load into the 32bit pool. The question I have i guess is why is this dll trying to load in the first place. It's not part of my application. Anyway to fix this issue:

Edit c:\windows\system32\inetsrv\config\applicationhost.config

In the section which has add - precondition="bitness64" to the rpcproxy line so that you have the following

Subversion

Projectlocker.com offers free svn repository

If the folder to be submitted into repo already exist, do the following:
1. right click to import (this imports the existing files into SVN)
2. right click to create repository (this indexes your existing files and allows you to use SVN normally)

Wednesday, September 16, 2009

Right align/justify in textarea, java

1. Font has to be first of all changed to monospace. Using something like:
txtAreaResult.setFont(new Font("monospaced",Font.PLAIN,12));

2. When we append character to the stringbuffer, we use this method
private String rightAlign(String input, int pad) {

int length = pad - input.length();

if (length < 0)
return input.substring(0,input.length());

StringBuffer buffer = new StringBuffer(pad);
for(int i=0; i<length; i++)
buffer.append(" ");

return new String(buffer.append(input));
}

3. we can use append like this:
StringBuffer results = new StringBuffer();
results.append(rightAlign("Months", 6));

Saturday, August 22, 2009

Radio button in datagrid

Radio buttons will not work by default inside a datagrid. The selection will be individual, because the groupname/id of the control is going to be different for each role automatically. Hence we need to make use of the literal control.

1. Insert literal control instead of the radiobutton control into the datagrid
2. The idea is to find the literal control inside the datagrid
3. Replace it with a radio button control with a fix name.

Something like:

if (e.Row.RowType == DataControlRowType.DataRow)
{
Literal literal = (Literal) e.Row.FindControl("RadioButtonMarkup");
literal.Text = String.Format("<input type='radio' name='couponId' id='coupon{0}' value='{0}' />", e.Row.RowIndex);
}

Friday, August 21, 2009

Datagrid ASP.NET C#

Inside the datagrid, insert a template column with the checkbox name chkSelect. The next column should be the ID of the column you want to obtain information from.

protected void btnModify_Click(object sender, EventArgs e)
{
for (int i = 0; i < couponGrid.Rows.Count; i++)
{
GridViewRow row = couponGrid.Rows[i];
bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;
if (isChecked)
{
// Column 2 is the ID column
String accessId = couponGrid.Rows[i].Cells[1].Text;
lbl.Text = lbl.Text + "haha" + accessId;
}
}
}
}

Eval("info") Eval of HTML fields in C#

If you try manipulating Eval binding tags within HTML, chances are you are not able to and you will get nasty errors. The only way to do it is to handle the process via a method. For example:

<asp:checkbox id="chkSelect" runat="server" checked="'<%#">' />

public bool checkOrNot(object id)
{
return true;
}

Thursday, August 20, 2009

Database

Select IDENTITY of the record after you insert, the XSD way.

Within the XSD file, create a new query -> create new standard procedure -> Select insert -> add a select query after the insert query, something like:

INSERT INTO [coupon] ([memberId], [categoryId], [couponCode], [couponName], [couponImage], [couponVideo], [couponSMSText], [couponExpiration], [couponDisclaimer], [couponPrice], [couponDiscount], [couponStart], [couponEnd], [couponLimit], [couponCreationDateTime], [couponStatus]) VALUES (@memberId, @categoryId, @couponCode, @couponName, @couponImage, @couponVideo, @couponSMSText, @couponExpiration, @couponDisclaimer, @couponPrice, @couponDiscount, @couponStart, @couponEnd, @couponLimit, @couponCreationDateTime, @couponStatus);SELECT couponId FROM coupon WHERE (couponId = SCOPE_IDENTITY())

After that, select the property of the query and select SCALAR mode instead of NonQuery