|
Hi,
I have a master page.There i had added an user control ie Menu.ascx.I had placed a header image,then user control,then content placeholder ie Child page and footer.
On click ok menu or submenu,the whole page refreshers.
I want the header and footer to be fixed.How to implement that,I had tried always.
Suggest some url or working sample.
u can refer my code.
Thanks
S.Guhananth.
|
|
|
|
|
Hi,
I used the following code to edit a wcf message using message inspector.
MemoryStream ms = new MemoryStream();
Encoding encoding = Encoding.UTF8;
XmlWriterSettings writerSettings = new XmlWriterSettings { Encoding = encoding };
XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(ms);
message.WriteBodyContents(writer);
writer.Flush();
string messageBodyString = encoding.GetString(ms.ToArray());
messageBodyString = messageBodyString.Replace("<n1>100</n1>", "<n1>200</n1>");
ms = new MemoryStream(encoding.GetBytes(messageBodyString));
XmlReader bodyReader = XmlReader.Create(ms);
Message originalMessage = message;
message = Message.CreateMessage(originalMessage.Version, null, bodyReader);
message.Headers.CopyHeadersFrom(originalMessage);
Actual body of the message was like
<s:Body u:Id="_0">
<Add xmlns="http://Microsoft.Samples.AdvancedFilters">
<n1>100</n1>
<n2>15.99</n2>
</Add>
</s:Body>
I wanted to change the value in the
<n1> tag from 100 to 200. But after executing the method
Message.CreateMessage(originalMessage.Version, null, bodyReader) , the body is shown like
<s:Body>... stream ...</s:Body>
|
|
|
|
|
It is in my opinion that you going about the process backwards.
When working with xml, no matter what the packaging is, wsdl, etc, you have to build the framework needed to write the xml file, edit, update, add, delete elements and child elements first.
Then you need to write the code needed to read and write it to the disk drive.
Now memory streams come into play, with memory stream, you can create a brand new xml file, store it in a memory stream, and transmit it to another server, or just send it to another function without ever touching the disk drive. While in memory, you can stuff it into your xml editor, modify it, store it back in the memory stream, and send it back out.
I use xsd to create a model of my xml, and compile it into a class object using xsd.exe /classes /vb /sample.sml to create sample.vb.
Then I use XMLTextWriter, to load up the sample.vb. The class wires up the xml structure, so an edit is as simple as sample.n1 = 200
|
|
|
|
|
|
This is a xsd template. I write them in Liquid Studio, but now I can write them from scratch. This one is very simple. I don't export the xml as a memory stream, but I do hold the entire xml in server memory, and when done, I write it back to the disk drive. The xsd, xml, program code all matches together. This is the fastest xml in asp.net. It is capable of doing 10 transactions per second, and I have 1 complex file with over 20,000 records in it, that can update really fast. This is how you write xml for DHL Express, UPS, Chase Payment Tech, PayPal, and any other web service that requires XML. It may be very difficult to comprehend at first, but I did all the heavy lifting for you.
You can save this as Sale_Messenger.xsd
="1.0"="utf-8"
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Sale_Messenger">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="Registered_Members">
<xs:complexType>
<xs:all>
<xs:element name="Name" type="xs:string" />
<xs:element name="EmailAddress" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Version" type="xs:string" />
<xs:attribute name="CreationDate" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:schema>
Now I run the xsd using LS, to confirm it makes a valid xml file.
Sale_Messenger.xml
="1.0"="utf-8"
-
- <Notification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Sep-WSDLS\TransactionNotifications\TransactionNotifications.xsd" Version="string" CreationDate="string">
- <Registered_Members>
<Name>string</Name>
<EmailAddress>string</EmailAddress>
</Registered_Members>
- <Registered_Members>
<Name>string</Name>
<EmailAddress>string</EmailAddress>
</Registered_Members>
- <Registered_Members>
<Name>string</Name>
<EmailAddress>string</EmailAddress>
</Registered_Members>
- <Registered_Members>
<Name>string</Name>
<EmailAddress>string</EmailAddress>
</Registered_Members>
</Notification>
So I have 2 files, Sales_Messenger.xsd, and Sales_Messenger.xml
I use xsd.exe on the xsd file - xsd.exe /vb /classes Sales_Messenger.xsd to produce a Sales_Messenger.vb class. Now I import the class into my project. You can find xsd.exe in VS 2005, 09, 10. Make the file and copy it into your project, include it.
Then I wrote a new class, to create a new file, update, and delete.
Private Sub Add_NewMember()
Dim FirstRecordFlag As Boolean = False
Dim Success As Boolean = True
Dim ContactName As String = False
Dim SecureContactName As String = Nothing
Dim Master_ContactName As String = Nothing
Dim ContactEmailAddress As String = Nothing
Dim SecureEmailAddress As String = Nothing
ContactName = txt_Setup_SalesMessenger_SendName_Field.Text.Trim
ContactEmailAddress = txt_Setup_SalesMessenger_SendEmail_Field.Text.Trim
SecureContactName = ice5commerce.common.EncryptDecrypt.Encrypt(ContactName)
SecureEmailAddress = ice5commerce.common.EncryptDecrypt.Encrypt(ContactEmailAddress)
Dim DataLocation As String = Nothing
DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/Messenger.xml")
'XML Data routines go here
Dim request_serializer As New XmlSerializer(GetType(Sale_Messenger))
AddHandler request_serializer.UnknownNode, AddressOf serializer_UnknownNode
AddHandler request_serializer.UnknownAttribute, AddressOf serializer_UnknownAttribute
Dim Reader As XmlTextReader = Nothing
Dim XmlRequest As New Sale_Messenger
Try
Reader = New XmlTextReader(DataLocation)
XmlRequest = CType(request_serializer.Deserialize(Reader), Sale_Messenger)
Reader.Close()
Reader = Nothing
Catch ex As Exception
FirstRecordFlag = True
End Try
Try
If FirstRecordFlag = True Then
Dim MyMembers_0 As Sale_MessengerRegistered_Members = New Sale_MessengerRegistered_Members
MyMembers_0.Name = SecureContactName
MyMembers_0.EmailAddress = SecureEmailAddress
Dim MyMembers() As Sale_MessengerRegistered_Members = {MyMembers_0}
'Now Lets Write out the file as a MemoryStream
Dim serializer As XmlSerializer
serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim XmlResponse As New Sale_Messenger
XmlResponse.Version = "1.4.2"
XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
XmlResponse.Registered_Members = MyMembers
'Now we have to write out a file for certification
Dim response_serializer As XmlSerializer = Nothing
response_serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim response_writer As StreamWriter = Nothing
response_writer = New StreamWriter(DataLocation)
response_serializer.Serialize(response_writer, XmlResponse)
response_writer.Close()
response_writer = Nothing
request_serializer = Nothing
serializer = Nothing
Else
Dim MyMembers() As Sale_MessengerRegistered_Members
Dim MyMembers_Length As Integer = 0
MyMembers = XmlRequest.Registered_Members
MyMembers_Length = MyMembers.Length
Array.Resize(MyMembers, MyMembers_Length + 1)
MyMembers(MyMembers_Length) = New Sale_MessengerRegistered_Members
MyMembers(MyMembers_Length).Name = SecureContactName
MyMembers(MyMembers_Length).EmailAddress = SecureEmailAddress
'Now Lets Write out the file as a MemoryStream
Dim serializer As XmlSerializer
serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim XmlResponse As New Sale_Messenger
XmlResponse.Version = "1.4.2"
XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
XmlResponse.Registered_Members = MyMembers
'Now we have to write out a file for certification
Dim response_serializer As XmlSerializer = Nothing
response_serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim response_writer As StreamWriter = Nothing
response_writer = New StreamWriter(DataLocation)
response_serializer.Serialize(response_writer, XmlResponse)
response_writer.Close()
response_writer = Nothing
request_serializer = Nothing
serializer = Nothing
End If
Catch ex As Exception
Success = False
Admin_Standard.Admin_PCI_Transction.Insert_PCI_Transaction("Display_SU_Sale_Messenger.vb", "MESSENGER", "ADD", ContactName, False)
End Try
If Success = True Then
txt_Setup_SalesMessenger_SendEmail_Field.Text = ""
txt_Setup_SalesMessenger_SendName_Field.Text = ""
txt_Setup_SalesMessenger_SendEmailConfirm_Field.Text = ""
Admin_Standard.Admin_PCI_Transction.Insert_PCI_Transaction("Display_SU_Sale_Messenger.vb", "MESSENGER", "ADD", ContactName, True)
End If
End Sub
Private Sub Delete_Member()
Dim Name As String = Nothing
Dim SecureName As String = Nothing
Dim DeleteName As String = Nothing
Dim SecureDeleteName As String = Nothing
If lb_SalesMessenger_ContactList_Field.SelectedIndex > -1 Then
Dim idx As Integer = 0
SecureDeleteName = lb_SalesMessenger_ContactList_Field.SelectedValue
DeleteName = ice5commerce.common.EncryptDecrypt.Decrypt(SecureDeleteName)
Dim DataLocation As String = Nothing
DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/Messenger.xml")
'XML Data routines go here
Dim request_serializer As New XmlSerializer(GetType(Sale_Messenger))
AddHandler request_serializer.UnknownNode, AddressOf serializer_UnknownNode
AddHandler request_serializer.UnknownAttribute, AddressOf serializer_UnknownAttribute
Dim Reader As XmlTextReader = New XmlTextReader(DataLocation)
Dim XmlRequest As New Sale_Messenger
XmlRequest = CType(request_serializer.Deserialize(Reader), Sale_Messenger)
Reader.Close()
Reader = Nothing
Dim MyMembers() As Sale_MessengerRegistered_Members
Dim MyMembers_Length As Integer = 0
MyMembers = XmlRequest.Registered_Members
MyMembers_Length = MyMembers.Length
Dim TestName As String = Nothing
Dim SecureTestName As String = Nothing
Dim SecureEmailAddress As String = Nothing
Dim ResizeArray_Flag As Boolean = False
Dim New_MyMembers() As Sale_MessengerRegistered_Members = MyMembers
Array.Resize(New_MyMembers, MyMembers.Length - 1)
Dim New_MyMembers_Length As Integer = New_MyMembers.Length
Dim jdx As Integer = 0
For idx = 0 To MyMembers_Length - 1
SecureTestName = MyMembers(idx).Name
SecureEmailAddress = MyMembers(idx).EmailAddress
TestName = ice5commerce.common.EncryptDecrypt.Decrypt(SecureTestName)
If Not String.Compare(TestName, DeleteName, True) = 0 Then
New_MyMembers(jdx).Name = SecureTestName
New_MyMembers(jdx).EmailAddress = SecureEmailAddress
jdx += 1
End If
idx += 1
Next
'Now Lets Write out the file as a MemoryStream
Dim serializer As XmlSerializer
serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim XmlResponse As New Sale_Messenger
XmlResponse.Version = "1.4.2"
XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
XmlResponse.Registered_Members = New_MyMembers
'Now we have to write out a file for certification
Dim response_serializer As XmlSerializer = Nothing
response_serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim response_writer As StreamWriter = Nothing
response_writer = New StreamWriter(DataLocation)
response_serializer.Serialize(response_writer, XmlResponse)
response_writer.Close()
response_writer = Nothing
request_serializer = Nothing
serializer = Nothing
Load_ListBox()
Admin_Standard.Admin_PCI_Transction.Insert_PCI_Transaction("Display_SU_Sale_Messenger.vb", "MESSENGER", "DELETE", DeleteName, True)
End If
End Sub
Private Function Does_SalesMessenger_XMLExist() As Boolean
Dim Context As HttpContext = HttpContext.Current
Try
Dim FileExist As Boolean = False
Dim DataLocation As String = Nothing
DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/Messenger.xml")
Dim f As New IO.FileInfo(DataLocation)
If f.Exists = True Then
FileExist = True
Else
FileExist = False
End If
f = Nothing
Return FileExist
Catch ex As Exception
Record_Admin_Setup_Errors(ex.Message.ToString, ex.StackTrace.ToString)
End Try
Context = Nothing
End Function
Protected Sub serializer_UnknownNode(ByVal sender As Object, ByVal e As XmlNodeEventArgs)
Dim Context As HttpContext = HttpContext.Current
'Context.Response.Write("Unknown Node:" & e.Name & ControlChars.Tab & e.Text)
End Sub
Protected Sub serializer_UnknownAttribute(ByVal sender As Object, ByVal e As XmlAttributeEventArgs)
Dim Context As HttpContext = HttpContext.Current
Dim attr As System.Xml.XmlAttribute = e.Attr
'Context.Response.Write("Unknown attribute " & attr.Name & "='" & attr.Value & "'")
End Sub
|
|
|
|
|
A little confused...i dont know whether this can be used in my case..if so which piece of code
modified 6-Dec-11 5:19am.
|
|
|
|
|
I'll have to get back to you later tonight. Let me try to figure out exactly what your doing.
|
|
|
|
|
hi friends
i am developing an asp.net project in c#.
In a master page i have a loginstatus control on the click of the control i have written:
protected void LoginStatus_LoggingOut(object sender, LoginCancelEventArgs e)
{
Session["UserId"] = "";
Session.Abandon();
Response.Redirect("../Login.aspx");
}
which redirects to the login page but from that page, if i type an aspx page in the site information tab where we used to type the webaddress it takes me to the page by the person name who just logged out
can anyone help me in this issue.
K.Gayathri
|
|
|
|
|
Hi Gayathri,
Please give
Session.Clear();
Session.Abandon();
Session.RemoveAll();
Respons.Redirect("Test.aspx");
This will clear ur session used.
Guhananth.S
|
|
|
|
|
try these lines on page load of every restricted page
if (Session["UserId"]==null)
{
Response.Redirect("Login.aspx");
}
and try
Session["UserId"] = null;
Session.Abandon();
Response.Redirect("../Login.aspx");
|
|
|
|
|
MalarGayu wrote: protected void LoginStatus_LoggingOut(object sender, LoginCancelEventArgs e) { Session["UserId"] = ""; Session.Abandon(); Response.Redirect("../Login.aspx"); }
There is no need of
MalarGayu wrote: Session["UserId"] = "";
You can directly use
MalarGayu wrote: Session.Abandon();
it will clear all variables of session and more over please use
Server.Transfer(""); inseted of
Response.Redirect("")
|
|
|
|
|
hi friends
thanks for all your replies
i tried:
protected void LoginStatus_LoggingOut(object sender, LoginCancelEventArgs e)
{
Session["UserId"] = "";
Session.Abandon();
Response.Redirect("../Login.aspx");
}
it is redirecting
but after i got to login.aspx and on the page i type another aspx page it is getting into that page with the last persons login id....
i dont want that to happen so how to do it
K.Gayathri
|
|
|
|
|
|
Hi,
On each menu or sub-menu-item click,the full page ie header,content placeholder and footer are refreshing.Need help.....
Suggest some url.or sample .net website where i can refer the code.
I had tried placing header and footer as seperate user control.But it failed on each menu item click or sub-menu item click.
Using Iframe makes peformance slower.
Thanks
S.Guhananth
|
|
|
|
|
That sounds like the proper behavior to me. Every button / hyperlink click regardless of being on a master page, or within a webform placeholder is going to generate a postback to the server.
If you want to use a button or hyperlink and not generate a complete postback, then you have to use Javascript, to SHOW / HIDE a control or object.
So you add onClientClick to the control object, and that will fire before a postback is generated.
onClientlick="return false;" will return false and cancel the next action.
return true will proceed to the next action.
|
|
|
|
|
Hi Experts,
I am working on mixed language web project. In App_Code folder, Created 2 folders with names "VBCode", "CSCode".
I added one class in VBCode folder with name "Class1.vb" and implemented 2 methods. And, I added one Class in CSCode folder with the name "Class2.cs".
My Requirements is, I want to create object for class "Class1.vb" in my "Class2.cs".
Is this Possible? if so, please give me the solution.
|
|
|
|
|
HI,
1) you need to create one class library project for VB.
2) add your VBClass in that project.
3) build VB project and add DLL file into CSProject.
4) Add reference in your CSClass.
5) use VB functions
Thanks
-Amit.
|
|
|
|
|
Thanks for your reply.
Other than this, is any other options?
|
|
|
|
|
No,as per my knowledge
actually in single project you can not have multiple languages supported for now.
do you have any problem creating different project ?
thanks
-amit
|
|
|
|
|
No problem.. but, checking for any other alternative for this problem.
|
|
|
|
|
if you like my solution please give rating
thanks
-amit.
|
|
|
|
|
|
I tried that years ago and it didn't work. Can't mix vb and csharp together in the same project. When you publish or run the project, the app_code folder gets compiled into a single or multiple dll's, not sure which but they don't mix.
It's kind of like having webforms with a mixture of cs and vb code behind pages.
You need to rewrite one of them if you want to keep them in the App_Code.
|
|
|
|
|
now I using IIS 5.1.
I created web application project using Visual Studio 2005 &
SQL Server 2005. then
I created virtual directory on IIS 5.1.
I attached database in MS SQL server 2005.
My web application contain ASP.Net 2.0 membership & login control.
When I browse my application from Browser using..
http://localhost/...
my application runs correctly.
But.
I cannot use Login control.
Login control just display when I run.
But it is not working, when I use log in control.
How I have to configure IIS 5.1
I am very confusing now, reading other help from Online.
Please help me.
|
|
|
|
|
Sounds like your not finished.
Did you setup your database and table, and enter a user and password in it.
I remember seeing a complete MS kit, in which you can download a starter program that already has all that going, and it sets up your sql server as well, so you get instant gratification within about an half hour.
|
|
|
|
|