Archive for the ‘asp.net’ Category

today i came across this issue once i enabled ‘Enable 32-bit Applications‘ to true on IIS

full error is

“The Module DLL ‘C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\isapi\spnativerequestmodule.dll’ could not be loaded due to a configuration problem. The current configuration only supports loading images built for a x86 processor architecture. The data field contains the error number. To learn more about this issue, including how to troubleshooting this kind of processor architecture mismatch error”

and then you browse the page it give’s HTTP Error 503. The service is unavailable since the app pool is stopped due to that error

Reason for the error
this because SharePoint’s  “spnativerequestmodule.dll ” only supports the 64 bit and when it tried to load on 32 bit environment it crashes

Resolution

run this command on command prompt

“%systemroot%\system32\inetsrv\AppCmd.exe” set config section:system.webServer/globalModules /[name=‘SPNativeRequestModule’].preCondition:integratedMode,bitness64″

This will direct the SPNativeRequestModule to only be loaded when the application pool is running in Integrated Mode and 64-bit application mode.

Advertisements

ASP.NET Web Forms versus MVC

Posted: Sunday, June 30, 2013 in .NET, asp.net

I found this blog post which talks about ASP.NET Web Forms versus MVC
Link

Gridview Linkbutton Postback Problem

Posted: Monday, April 8, 2013 in .NET, asp.net

Some of the Devs in my team had a problem with linkbuttons inside a Gridview template field.

When they clicked on the linkbutton it didn’t postback.

I thought it’s an application wide issue, but in some pages it worked.

Then it came into my mind the issue is coz of the validation controls in some of the page.

When use clicks on a gridview’s  linkbutton, if the page have validation controls, it will fire them,

BUT IT WON’T SHOW THE VALIDATION MESSAGE to the end user. So the user thinks it’s an another issue.

To fix this you can add CausesValidation=”false” attribute to the linkbutton.

Ajax ComboBox Result List Position Problem

Posted: Tuesday, January 22, 2013 in asp.net

If you use the Ajax control toolkit’s ComboBox control inside a DIV element which It’s position set as relative, then the result list of the ComboBox will come in an odd location. Normally at the bottom of the parent div.

This happen because of the parent div position and the ComboBox’s list also showing based on that setting.

To fix this
1)      Add CssClass=”WindowsStyle” to the combobox tag

2)      Add this to the page
<style>
.WindowsStyle .ajax__combobox_itemlist
{position:inherit !important; }
</style>

Then the combobox result list will get its immediate parent’s position
On a side note, if you see the combobox is miss align with out controls add RenderMode=”Block”

Hope this helps.

The Virtual ASP.NET Conference

Posted: Sunday, July 15, 2012 in asp.net, Microsoft

go and join for the The Virtual ASP.NET Conference on july 17th and 18th for free.
http://www.aspconf.net/

Lets say you need to add itemtemplate dynamically to your gridview and also wants to data bind the sub class which loads with your main class.

Ex:- Person.Car.Type
If you bind list of person as the data source, in the data binding event of the control you can simply call
DataBinder.Eval(container.DataItem, “myCar.type”);

This is a sample code you can use .

protected void Page_Load(object sender, EventArgs e)
{
List<person> pl = new List<person>();
for (int i = 0; i < 5; i++)
{
person p = new person();
p.age = i.ToString();
p.name = “name” + i.ToString();
p.myCar = new car();
p.myCar.type = “Nissan” + i.ToString();
pl.Add(p);
}

TemplateField tmp = new TemplateField();
tmp.ItemTemplate = new TemplateData();
GridView1.Columns.Add(tmp);

GridView1.DataSource = pl;
GridView1.DataBind();
}
}

class person
{
public string name { get; set; }
public string  age { get; set; }
public car myCar { get; set; }
}

class car
{
public string name { get; set; }
public string type { get; set; }
}

public class TemplateData : ITemplate
{
void ITemplate.InstantiateIn(Control container)
{
Label lb = new Label();
lb.ID = “lb”;
lb.DataBinding += new EventHandler(lb_DataBinding);
container.Controls.Add(cmd);
}

void lb_DataBinding(object sender, EventArgs e) {
Label lb = (Label)sender;
GridViewRow container = (GridViewRow)lb.NamingContainer;
object dataValue = DataBinder.Eval(container.DataItem, “myCar.type”);
lb.Text = dataValue.ToString();
}

Page_LoadComplete not calling from User Control

Posted: Wednesday, January 18, 2012 in asp.net

If you add Page_LoadComplete method to a user control it’s not getting called like Page_load or Page_init. For this what you can do is call the main page’s Page_LoadComplete event from user control. Add an event handler for LoadComplete event in the user control’s page init

protected void Page_Init(object sender, EventArgs e)
{
this.Page.LoadComplete += new EventHandler(Page_LoadComplete)
}