|
HI All,
Kindly, provide me a code sample how to post a asp.net forms data to a third party API in XML format and handle the out XML in asp.net .
...Hotelbooking API ...
Please its very urgent .
THanks & Regards,
Martin.
|
|
|
|
|
I already done it for you, please check you email...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
If you are providing a solution, then you should post it here so others can see it.
|
|
|
|
|
It was urgent - so I just forgot the icon...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
should have known.
|
|
|
|
|
|
Hi,
First up, sorry if I haven't used the correct name for this interface style in the title. I'm not sure if there even is a correct name! What I am trying to do is to have a treeview on the left of the screen and an AJAX panel on the right. When a node is selected, a User Control is added to the panel (different controls depending on the type of the node).
This part works.
My problem is twofold.
1. If I select a node in the tree, the SelectedNodeChanged event fires, and causes the User Control to be correctly displayed. If, however, I click on the node that is already selected, the User Control disappears. I can only assume AJAX is updating the panel, but I can't figure out why. There doesn't appear to be an OnClick event for a TreeView..
2. When I click on the OK or Cancel buttons within my User Control, I want the postback to update my application and then leave the node selected with the User Control still displayed (Obviously, Cancel results in the contents being wiped...) Again, clicking the button causes the User Control to disappear.
Code:
Main Page
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="HomeLink">
<asp:HyperLink ID="HyperLink1" runat="server" CssClass="home" ImageUrl="~/Images/105329-3d-glossy-orange-orb-icon-business-home5.png"
NavigateUrl="~/Default.aspx">
</asp:HyperLink>
</div>
<asp:Panel ID="TreeArea" runat="server" CssClass="TreeArea">
<%----%>
<asp:TreeView ID="TreeViewSettings" runat="server" ExpandDepth="0" PopulateNodesFromClient="False"
CssClass="TreeViewSettings" OnSelectedNodeChanged="TreeViewSettings_SelectedNodeChanged">
</asp:TreeView>
</asp:Panel>
<asp:Panel ID="EditFormArea" runat="server" CssClass="SettingsFormArea">
<asp:UpdatePanel ID="UpdatePanelEdit" runat="server">
<ContentTemplate>
<asp:Panel ID="PanelEdit" runat="server">
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TreeViewSettings" EventName="SelectedNodeChanged">
</asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
</asp:Content>
protected void TreeViewSettings_SelectedNodeChanged(object sender, EventArgs e)
{
reload();
}
protected void reload(){
TreeNode selection = TreeViewSettings.SelectedNode;
string[] SelectedDetails = selection.Value.Split(new char[] {'|'});
RegionEditor RegionEditorForm = LoadControl("~/TheSettings/RegionEditor.ascx") as RegionEditor;
RegionEditorForm.RegionID = int.Parse(SelectedDetails[1]);
RegionEditorForm.CancelClick += new EventHandler(RegionEditorForm_CancelClick);
PanelEdit.Controls.Add(RegionEditorForm);
AsyncPostBackTrigger CancelTrigger = new AsyncPostBackTrigger();
CancelTrigger.ControlID = RegionEditorForm.UniqueID;
CancelTrigger.EventName = "CancelClick";
UpdatePanelEdit.Triggers.Add(CancelTrigger);
}
void RegionEditorForm_CancelClick(object sender, EventArgs e)
{
reload();
}
User Control:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RegionEditor.ascx.cs"
Inherits="Shedulinator.TheSettings.RegionEditor" %>
<% if (false)
{ %>
<link rel="Stylesheet" type="text/css" href="../Styles/Site.css" />
<% } %>
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/106660-3d-glossy-orange-orb-icon-transport-travel-compass2.png"
CssClass="SettingsIcon" />
<asp:Panel ID="Panel1" runat="server" CssClass="SettingsFormPanel">
<asp:Label ID="LabelRegion" runat="server" Text="Region Name:"></asp:Label>
<asp:TextBox ID="TextBoxRegionName" runat="server"></asp:TextBox>
<asp:Button ID="ButtonCancel" runat="server" CssClass="SettingsButton"
Text="Cancel" onclick="ButtonCancel_Click" />
<asp:Button ID="ButtonOK" runat="server" CssClass="SettingsButton" Text="OK"
onclick="ButtonOK_Click" />
</asp:Panel>
public partial class RegionEditor : System.Web.UI.UserControl
{
public event EventHandler CancelClick;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ButtonCancel_Click(object sender, EventArgs e)
{
if (CancelClick != null)
{
CancelClick(this, new EventArgs());
}
}
}
Ideas, anyone?
Thanks!
|
|
|
|
|
The user control wont' persist upon post back, so it goes away.
I think it's in the user control, but I can't tell because there is not code for it.
You may want to start using Page.IsPostback to check the life cycle of the page before loading and unloading things
Member 10409255 wrote: There doesn't appear to be an OnClick event for a TreeView..
You can program events
SelectAction = TreeNodeSelectAction.Expand
Member 10409255 wrote: I want the postback to update my application and then leave the node selected
I don't understand that, you want to clear the tree view, or change the selected node?
Turn the visibility off, or change the CSS display to none.
Or change the node selected in code behind.
|
|
|
|
|
Thanks for looking at this for me!
jkirkerx wrote: You can program events
SelectAction = TreeNodeSelectAction.Expand
I'm not sure I follow here. There isn't necessarily an expansion going on. Or does this event fire at other times?
jkirkerx wrote: I don't understand that, you want to clear the tree view, or change the selected node?
Neither. The tree is to hold information about users, groups and other setup information. If I select a user, then the User Control to view / edit user information is loaded into the right hand pane. At the bottom of the control, I have an OK button and a Cancel button. When I click OK, then I want the back-end database updating (I can do that) but I want the user Node in the tree to remain selected and the User Control to remain visible (due to the user node being selected.)
|
|
|
|
|
You can the select action of the node group to 4 choices - Just FYI
TreeNodeSelectAction.Expand -
TreeNodeSelectAction.None
TreeNodeSelectAction.Select - Selecting a node
TreeNodeSelectAction.SelectExpand - I guess expanding a folder
Controls that are made in onInit or PreInit are persistent. They will remain after a postback trip to the server.
Controls that are made after Init, like on Page.Load are not persistent, and will not survive a postback. Even if you load the control again after postback, the data in the textbox will be lost, because it's a new version of the control.
So either you redesign your form, to load the control in Init, so the control stays, or you have to do something else.
I would probably load all the controls, and turn off the visibility. Then on node select, turn on the visibility of the control you need.
You can also use CSS, in which you just toggle the "display" to inline-block or none.
I not sure how you wrote the code, if your using webform, then place all the controls on the form.
If your using code behind to generate the page, then use PreInit, or I think you can override an event using
Protected Overrides Sub OnInit(ByVal e as System.EventArgs)
'Load your user controls here.
End Sub
Keep in mind, that all controls or HTML markup has to be made in OnInit to persist. You use Page.Load just to populate the data in the HTML markup.
|
|
|
|
|
Thank you for all the help!
Turns out that it was a Noob mistake. I hadn't wrapped my head around ViewState and so on. Managed to get it working now
|
|
|
|
|
I need to POST a set of XML data to a web device. I'm most familiar with ASPX / c#. Basically the user lands on my page and I retrieve two parameters from the URL and store them as Session Variables (like this):
<script runat="server">
Sub Page_Load()
dim MA as String
MA = Request.QueryString("MA")
Session.Add("MAC_ADDRESS", MA)
Message.Text = Session("MAC_ADDRESS")
End Sub
</script>
I realize the above is currently VB, but I'm going to switch this to c# (as I'm more familiar with it). I need to use these session variables to POST XML formatted data to a URL:
POST TO: ([IP_Address]/command.xml)
Example XML:
<?xml version="1.0" ?>
<!DOCTYPE ABC "UserAdd.dtd">
<ABC COMMAND="USER_ADD" MAC_ADDR="Session("MAC_ADDRESS")>
<EXPIRY_TIME UNITS="SECONDS">60</EXPIRY_TIME>
</ABC>
Once the Device receives the command, it sends back a response (OK or Error), I also need to retrieve and verify the response (just a Response.Write to screen would be fine). I've never done anything like this before so any help is greatly appreciated!
Thanks!
Brad
EDIT:
Here is a Javascript version that WORKS. This is based on a form where the user fills out the fields that makeup the XML (I'm only using MAC_ADDRESS right now, none of the others). If Someone Could help me translate whats happening here to c# in a simpler way, I would be MOST appreciative!
function SendXML()
{
var usg = template.XMLDocument
clearResults();
usg.async = false;
usg.preserveWhiteSpace = false;
BuildEls(usg);
document.all("xmlCommand").insertAdjacentText("BeforeEnd",
usg.xml);
var httpOb = new ActiveXObject("Microsoft.XMLHTTP");
httpOb.Open("POST", usgAddr, false);
httpOb.send(usg);
document.all("xmlResponse").insertAdjacentText("BeforeEnd",
httpOb.responseXML.xml);
}
modified 5-Sep-14 15:06pm.
|
|
|
|
|
Gridview with Textbox Control how to pass JQuery Scrpt
using Asp.net With C#
|
|
|
|
|
I don't understand what you are asking.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have a word document that needs to be converted to HTML page. Basically, the doc is the study material for Economics. So there will be Page Content Listing, Chapter Headings, Subheadings, small captions, titles , images, etc. Some texts need to be bold, some to be italic, and some other needs to be underlined. I need to apply proper styles for these contents.
I can convert the document to html page using the code mentioned in this link. But I am not sure how to apply the required styles? Should I use XSLT or simple CSS to convert this html page to formatted one?
|
|
|
|
|
You should use VSTO. Open the document with it and save as HTML...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
We are using the code below to pass an user password to a MVC web service encoding its value. The problem that when we run a HP fortify web scan on the application we are getting "password management heap inspection fortify" issues with passing the password to the web service. The finding has to do with not clearing out the password. Can anyone provide any advise?
string username = collection["username"].ToString();
string password = collection["password"].ToString();
/////LOGIN USER
string passurl = System.Web.HttpUtility.UrlEncode(Password);
response = client.GetAsync("Registration?username=" + Username + "&password=" + passurl + "&edi=" + "" + "&isEdi=" + false).Result;
responseBodyAsText = response.Content.ReadAsStringAsync().Result;
statuses = JObject.Parse(responseBodyAsText);
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(UserCred));
using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(statuses.ToString())))
{
usercred = (UserCred)serializer.ReadObject(ms);
}
Session["userData"] = usercred;
Session.Add("Authenticated", "True");
return RedirectToAction("Index", "Home", usercred);
modified 3-Sep-14 14:33pm.
|
|
|
|
|
//string FileName = "";
string _fileName = FileName.Replace("?",@"\");
string fileType = Path.GetExtension(_fileName);
FileStream str = File.OpenRead(_fileName);
System.IO.BinaryReader r = new System.IO.BinaryReader(str);
string fileclass = "";
byte buffer;
str.Seek(0, SeekOrigin.Begin);
buffer = r.ReadByte();
fileclass = buffer.ToString();
buffer = r.ReadByte();
fileclass += buffer.ToString();
r.Close();
return Convert.ToString(SR_BAL_Common.MatchFileType(fileType.ToUpper(), fileclass.ToString()));
Ajax Method
$.ajax({
type: "POST",
url: _URL,
data: '{"FileName":"' + replaceableString + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
beforeSend: function () { },
complete: function () { },
error: function (xhr, desc, exceptionobj) { alert(xhr.responseText); },
success: function (Result, Status) {
alert(Result.d);
if (Result.d == "0") {
alert("Please select valid CV to upload. \nOnly .pdf, .doc, .docx, .html, .htm, .txt and .rtf files are allowed.");
return false;
}
}
});
The above code is working on Local but on server it giving error 500 will please suggest any why this error is coming.
Pawan Jha
|
|
|
|
|
You're passing the path of a file on the client to the server, and then trying to open that file on the server.
It works when you're running it locally, because the client and server are the same machine. When you deploy to a real server, the client and server are different machines, and the server has no access to the client's file system.
You need to post the contents of the file to the server, and process the posted contents. Since you're using an AJAX request, you'll need to use the FormData object:
NB: This is not supported[^] in IE9 or earlier.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
I trying get ssrs 2008 up and running on a new server.
I got everything to work just like it dit on my old server and I can deploy reports and view them in the report manager, but I cannot seem to view a report from asp.net applications either in a reportviewer or using the reportexecutionservice. I keep getting the error: The request failed with HTTP status 401: Unauthorized
This is the first time that I had to set up ssrs so I do not know whether I have missed something. I tried to make everything the same as the instance on my old server.
Any assistance would be appreciated.
The following code is what I use for the web execution service and it used to work fine.
This code basically just renders the report as a pdf and downloads it.
rs.Credentials = New System.Net.NetworkCredential("username", "password", "domainname")
Dim reportPath As String = "/OLS/" & ReportName
Dim ResultStream() As Byte
Dim StreamIdentifiers() As String = Nothing
Dim optionalParams(1) As ParameterValue
Dim OptionalParam As String = Nothing
Dim optionalWarnings As WebReference.Warning() = Nothing
optionalParams(0) = New WebReference.ParameterValue
optionalParams(0).Name = "WarningID"
optionalParams(0).Value = Session("ID")
' Create and set the content type string
Dim contentType As String = "application/pdf"
Dim historyID As String = Nothing
Dim devInfo As String = "<deviceinfo><toolbar>False"
Dim format As String = "PDF"
Dim extension As String = ""
Dim encoding As String = ""
Dim mimeType As String = ""
Dim warnings As Warning() = Nothing
Dim streamIDs As String() = Nothing
Dim WarningID As String
WarningID = Session("ID")
Dim execInfo As New ExecutionInfo
Dim execHeader As New ExecutionHeader()
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
rs.SetExecutionParameters(optionalParams, "en-us")
Dim FilePath As String
FilePath = "c:\WebDocuments\OLS\TempDocs\" & Session("EmployeeID") & "\"
Try
ResultStream = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)
execInfo = rs.GetExecutionInfo()
Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)
Catch err As SoapException
'Console.WriteLine(e.Detail.OuterXml)
End Try
' Write the contents of the report to an MHTML file.
Try
Dim stream As FileStream = File.Create(FilePath + WarningID + ".pdf", ResultStream.Length)
Console.WriteLine("File created.")
stream.Write(ResultStream, 0, ResultStream.Length)
Console.WriteLine("Result written to the file.")
stream.Close()
Catch err As Exception
Console.WriteLine(err.Message)
End Try
'insertDownload(ClientID)
'Response.Redirect(Request.Url.ToString)
' ResultStream = rs.Render("/" & sReportPath & "/" & sReportName, "PDF", Nothing, "<deviceinfo><streamroot>/RSWebServiceXS/", optionalParams, Nothing, Nothing, OptionalParam, OptionalParam, optionalParams, optionalWarnings, StreamIdentifiers)
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Type", contentType)
Response.AddHeader("Content-Disposition", "attachment;filename=" & WarningID & ".pdf")
Response.BinaryWrite(ResultStream)
Response.Flush()
Response.End()
End Using
|
|
|
|
|
Can you please tell me a sample format of username and password. Most probably it will be the issue of authorization. It will be happen when the username and password is correct or the user trying to access have no permission to access that server.Also try to pass username without specify domain.
|
|
|
|
|
Thanks for your response.
I am using the system administrator account details and I am not specifying the domain. I use something like this:
Username: administrator
Password: mylxghs
|
|
|
|
|
I hope that's not your real administrator password!
If it is, you should change it immediately.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|