Thursday, January 24, 2013
UpdatePanel doesn't like the ViewState being tampered with!
Symptom:
Previous instances of RadAjaxPanel were replaced with UpdatePanel. Suddenly, controls within that page no longer postback.
Sample Code:
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
</ContentTemplate>
</asp:UpdatePanel>
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Text = DateTime.Now.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
Button2.Text = DateTime.Now.ToString();
}
When alternating clicks between Button1 and Button2, I would expect that the clicked button would update with the current time. Instead, the button values were clearing.
Solution:
It turns out this was specific to a certain page. On a normal page, it worked fine. On the page with these symptoms, I discovered it was related to a solution that implimented due to a large ViewState. I was overriding SavePageStateToPersistenceMedium and LoadPageStateFromPersistenceMedium and that was causing the UpdatePanel to fail when saving the ViewState information to the Cache.
Can't publish files in Visual Studio 2012
Symptom:
When publishing files to a local drive with Visual Studio 2012, there seems to be no files in the destination directory.
Additional Symptoms:
- The My Project folder has some read-only .pubxml files that contain settings for publishing. Deleting them seems to make deploying work again.
- After a Get Latest from TFS, my previously successful Publish settings are overridden with another team member's settings.
Solution:
When publishing a project, give the profile name something unique like your own name. This will make a seperate .pubxml file with your settings. Other team members using unique profiles with their own names should no longer affect your settings. When they change their profile settings, their .pubxml file will be checked out and updated accordingly.
Friday, November 23, 2012
Not receiving MMS w/ ting on my Samsung SIII
Symptom: People did not receive pictures we sent and we did not receive pictures that they sent.
Environment:
Pam using a Samsung Galaxy SIII, stock rom, rooted, but without the latest patch.
James using a Samsung Galaxy SIII, CM10 rom, using cm-10-20121118-NIGHTLY
Solution for Pam's phone:
Solution for James's phone:
Environment:
Pam using a Samsung Galaxy SIII, stock rom, rooted, but without the latest patch.
James using a Samsung Galaxy SIII, CM10 rom, using cm-10-20121118-NIGHTLY
Solution for Pam's phone:
- dial ##DATA#
- select Edit
- enter MSL (obtain from ting, or go to the website, find Account, Device Settings, Select the phone number, and the MSL is under it)
- select Others
- select MMSC URL
- change from http://mms.sprintpcs.com to http://mms.plspictures.com
- save and reboot
Solution for James's phone:
- It seems there was no obvious way to natively edit the MMS setting with CM10. Various sources indicated I needed to edit a file. To make things easier, I installed DropBear SSH server.
https://play.google.com/store/apps/details?id=me.shkschneider.dropbearserver - SSH in, then remount the file system:
- root@android:/ # cd /system/etc
- root@android:/system/etc # mount -o rw,remount /system
- Using vi, I altered /system/etc/apns-conf.xml to replace references for mms.sprintpcs.com to be mms.plspictures.com
- Rebooted, MMS now works. Reboot may not have been necessary even.
Wednesday, October 3, 2012
Getting the Repeater row index from the LinkButton
This is one I am posting for my own reference so I can find it easier... When Clicking a LinkButton in a Repeater, I needed the index available to modify a cached DataTable.
Situation: Getting the Repeater row index from the LinkButton
Solution:
LinkButton lnkButton = sender as LinkButton;
int RepeaterItemIndex = ((RepeaterItem)lnkButton.NamingContainer).ItemIndex;
Credit to kaushalparik27 at http://forums.asp.net/t/1333400.aspx/1
Tuesday, October 2, 2012
Scroll after postback
Situation: Button inside of a GridView fires the Command event and needs to scroll to the bottom of the page.
Solution: Use an anchor tag, then use ClientScript.RegisterStartupScript on the end of the event method to scroll to it.
Credit goes to http://forums.asp.net/t/1311972.aspx/1
Monday, August 13, 2012
SQL string splitter
I really prefer to give credit for these types of things, but I don't remember where I found it :(
Basic syntax... select dbo.FN_STRING_HELPER_SPLIT('My name is James', ' ', 4) will return 'James'
CREATE FUNCTION [dbo].FN_STRING_HELPER_SPLIT
(
@strToSplit as varchar(4000),
@delimiter as varchar(50),
@columnToReturn as int
)
RETURNS varchar(25)
AS
BEGIN
-- Declartion of the return variable
DECLARE @i as int
DECLARE @occurrences as int
DECLARE @delimiterIndex as int
DECLARE @actSplitValue as varchar(4000)
-- T-SQL statements to compute the return value here
SET @i = 1
SET @delimiterIndex = 1
WHILE @i <= @columnToReturn
BEGIN
SET @delimiterIndex = CHARINDEX(@delimiter, @strToSplit)
-- if not found end while
SET @actSplitValue = @strToSplit
IF @delimiterIndex = 0 BEGIN
BREAK
END
SET @actSplitValue = LEFT(@strToSplit, @delimiterIndex - 1)
-- SUBSTRING(string, von, bis)
SET @strToSplit = SUBSTRING(@strToSplit ,@delimiterIndex +1, LEN(@strToSplit)- @delimiterIndex)
SET @i = @i + 1
END
-- the result of the function
RETURN @actSplitValue
END
Friday, May 25, 2012
Rendering a UserControl as string
I was given the task of creating an HTML based
email that sent the contents of a webform. This is where I explored the
possibility of rendering an independant usercontrol into a string.
I did some searching and came across code like
this:
Page pageHolder = new Page();
PrintVersion pv1 =
(PrintVersion)pageHolder.LoadControl("PrintVersion.ascx");
pv1.BindData();
pageHolder.Controls.Add(pv1);
StringWriter output = new
StringWriter();
HttpContext.Current.Server.Execute(pageHolder,
output, false);
return output.ToString();
I was getting errors like:
System.Web.HttpException: Error
executing child request for handler System.Web.UI.Page'.
System.Web.HttpUnhandledException:
Exception of type 'System.Web.HttpUnhandledException' was thrown.
System.Web.HttpException:
Control 'ctl00_listItems' of type 'Repeater' must be placed inside a form tag
with runat=server.
I stumbled on this article:
It suggested overriding a method (notice no call
to the base method)
public class PageOverride :
System.Web.UI.Page
{
public override
void VerifyRenderingInServerForm(System.Web.UI.Control control) {}
}
Worked perfectly!
Subscribe to:
Posts (Atom)