Wednesday, December 19, 2007

Handle ajax slider events

<script type="text/javascript">
<!--

function pageLoad(sender, e) {
var startslider = $find('startSliderBehavior');
startslider.add_valueChanged(onValueChanged);
onStartValueChanged(startslider, null);
}

function onValueChanged(sender, e) {
//sender is the startSliderBehavior object
time = sender.get_Value();
clientID = '<%= FindNestedControl(fvMain, "lblStartSlider") == null ? "" : FindNestedControl(fvMain, "lblStartSlider").ClientID %>'
if (clientID != "")
document.getElementById(clientID).innerHTML = ConvertIntToTimeString(time);
}
-->
</script>

<asp:TextBox ID="tbSliderStart" runat="server" Style="right: 0px" Text='<%# Bind("AssetReferenceMetaStart") %>' />

<asp:Label ID="lblStartSlider" runat="server" Style="font-size: 80%;" Text="00:00:00" />

<ajaxToolkit:SliderExtender ID="SliderExtender1" runat="server" EnableHandleAnimation="true" TargetControlID="tbSliderStart" Minimum="0"Maximum="7200" BehaviorID="startSliderBehavior" />

Wednesday, October 17, 2007

FileUpload control causes 404 error

This can occur when the size of the file being uploaded is outside the proscribed limits.
From The MSDN Article:
The default size limit is 4096 KB (4 MB). You can allow larger files to be uploaded by setting the maxRequestLength attribute of the httpRuntime element. To increase the maximum allowable file size for the entire application, set the maxRequestLength attribute in the Web.config file. To increase the maximum allowable file size for a specified page, set the maxRequestLength attribute inside the location element in Web.config.

Access the return value of an ObjectDataSource Insert method

Handle the OnInserted event of the ObjectDataSource and use the ObjectDataSourceStatusEventArgs.ReturnValue property

Thursday, October 04, 2007

Session state

I set my session state timeout to 1 minute, but after a minute has elapsed without interacting with the site, I can still browse to other pages without having to log in again. What is happening?

There is another timeout that you should set in the web.config file:
<forms timeout="1"/>

There is also an issue related to IIS where processes are recycled after being idle for a set period of time. This article explains more

Wednesday, September 05, 2007

Stack Trace - Get name of current method

System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
string methodName = st.GetFrame(0).GetMethod().Name;

Saturday, January 13, 2007

Find the databse ID of a gridview row

Convert.ToUInt32(gridview.DataKeys[rowIndex].Value)

getElementById with Master Pages

When using master pages and at certain other times the names of objects on an asp page get mangled to prevent name clashes. This makes it so that any javascript that references these objects is no longer able to find the element by its original name. To work around this use the following syntax with the getElementById


document.getElementById("<%= [ObjectName].ClientID %>")

Change [ObjectName] to be the name of the object you want to find.