Latest

Movies:

Rise of the Planet of the Apes Fifth Element, The Hangover Part II, The

Photoalbums:

Christmas 2011 Leander, 1 day old Autumn Kongsberg
Latest tweets
October 2011

Response.Redirect inside an UpdatePanel

2011-10-18 16:37
Recently I've had more and more pages displaying unexpected behaviour.
I had an UpdatePanel with a button inside it. The button's Click event performed a Response.Redirect(), but nothing happened.
The Javascript error console showed the following error message:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.


After some googling it seems that ASP.Net doesn't quite support Response.Redirect() inside UpdatePanels any more.

The solution was to make sure the button actually performed a full postback of the webpage, and not only a partial postback (as it would do because it was inside an UpdatePanel).

There are two ways of doing this. First the easy way.

<asp:UpdatePanel runat="server">
    <ContentTemplate>
        <asp:Button ID="MyButton" runat="server" />
    </ContentTemplate>
    <Triggers>
        <asp:PostBackTrigger ControlID="MyButton" />
    </Triggers>
</asp:UpdatePanel>


Here you're basically telling the UpdatePanel that "MyButton" should perform a full postback instead of a partial one.

My problem was a bit more complicated, though, because "MyButton" was inside a GridView. This complicated things a bit, but not too much. Mainly you have to have access to the ScriptManager.

Add the OnRowDataBund event to your GridView. In this event do the following:

protected void MyGridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        Button MyButton = (Button)e.Row.FindControl("MyButton");
        ScriptManager1.RegisterPostBackControl(MyButton);
    }
}


So instead of telling the UpdatePanel that your button should do a full postback, you're telling the ScriptManager the same thing.
Doing this in code-behind would obviously work for the first example as well.
Posted in .Net, Programming | No Comments

Samba/Winbind connection issues

2011-10-15 13:08
I recently had to reconfigure my linux (Ubuntu 10.04 LTS) servers.
I had previously used these two howto's to configure my servers.
Suddenly one of them refused to properly connect with various error messages:

# wbinfo -p
Ping to winbindd failed

# wbinfo -u
Error looking up domain users

# wbinfo -t
checking the trust secret via RPC calls failed
Could not check secret

After a week of googling I finally found the following solution, which did the trick for me.

Stop smbd, nmbd and winbindd (make sure they are really dead using ps. winbindd still lingered after I stopped the service)
Delete the linux computer from the Primary Domain Controller (using the Management Console)
Delete the secrets database (/var/lib/samba/secrets.tdb)
Join the domain again
Start the daemons (smbd, nmbd and winbindd)
Test the winbind commands to see that everything is working
Posted in Linux, Technology | No Comments

Trying a new thing with my blog

2011-10-15 11:23
Because I'm using Twitter, Facebook and Google+ I haven't really made any good posts to my blog for a while.
I'm trying to remedy this by taking my blog in a new direction.
As a "Technology Enthusiast" I regularly get stuck in various situations where I have to do a lot of googling. Some times I can google for a week and not find a solution.
When I finally do find a solution I've decided I should write about it on my blog so that others can (maybe) find the solution as well.
So don't be surprised when you see lots of technical stuff popping up on this blog instead of the usual ramblings about what happens (or not) in my life.
Posted in Life, Technology | No Comments