Hi All,
I wonder if someone can help. I have just started using ajax and am converting an established application. It uses dynamically created controls to enter parameters for crystal. I have now got a panel that l holds the crystal component, and with testing of directly fed parameters this works fine. As soon as i try and use my dynamic componenets it can't see them. I have gathered this has got something to do with viewstates. I have seen several examples of how to fix this but they are all in C# and the application is in vb. Can anybody step me through this please as i sem to be missing something.
hello,
show me the examples that you found in C# ... i might be able to convert it back to VB for you ... =)
Ttry this online link for converting C# to VB Code...
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
Hi
My conversion is below,
Protected Overrides Function LoadPageStateFromPersistenceMedium()As Object Dim viewStateAs String = Request.Form("__VSTATE")Dim bytesAs Byte() = Convert.FromBase64String(viewState) bytes = Decompress(bytes)Dim formatterAs LosFormatter =New LosFormatterReturn formatter.Deserialize(Convert.ToBase64String(bytes))End Function Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewStateAs Object)Dim formatterAs LosFormatter =New LosFormatterDim writerAs StringWriter =New StringWriter() formatter.Serialize(writer, viewState)Dim viewStateStringAs String = writer.ToString()Dim bytesAs Byte() = Convert.FromBase64String(viewStateString) bytes = Compress(bytes) ScriptManager.RegisterHiddenField(Me,"__VSTATE", Convert.ToBase64String(bytes))End Sub
Public Function Compress(ByVal dataAs Byte())As Byte()Dim outputAs MemoryStream =New MemoryStreamDim gzipAs GZipStream =New GZipStream(output, CompressionMode.Compress,True) gzip.Write(data, 0, data.Length) gzip.Close()Return output.ToArray()End Function Public Function Decompress(ByVal dataAs Byte())As Byte()Dim inputAs MemoryStream =New MemoryStream() input.Write(data, 0, data.Length) input.Position = 0Dim gzipAs GZipStream =New GZipStream(input, CompressionMode.Decompress,True)Dim outputAs MemoryStream =New MemoryStream()Dim buffAs Byte()Dim readAs Integer = -1 read = gzip.Read(buff, 0, buff.Length)While (read > 0) output.Write(buff, 0, read) read = gzip.Read(buff, 0, buff.Length)End While gzip.Close()Return output.ToArray()End Function
And the original code was:
protected override object LoadPageStateFromPersistenceMedium()2 {3string viewState = Request.Form["__VSTATE"];4byte[] bytes = Convert.FromBase64String(viewState);5 bytes = Compressor.Decompress(bytes);6 LosFormatter formatter =new LosFormatter();7return formatter.Deserialize(Convert.ToBase64String(bytes));8 }9protected override void SavePageStateToPersistenceMedium(object viewState)10 {11 LosFormatter formatter =new LosFormatter();12 StringWriter writer =new StringWriter();13 formatter.Serialize(writer, viewState);14string viewStateString = writer.ToString();15byte[] bytes = Convert.FromBase64String(viewStateString);16 bytes = Compressor.Compress(bytes);17 ScriptManager.RegisterHiddenField(this.updVS,"__VSTATE", Convert.ToBase64String(bytes));18 }thanks again
No comments:
Post a Comment