|
Hi all,
I have an ASP.Net MVC application using Web API Controller, I want to call get method for Button Click using TypeScript, here is my Web Api Controller and its action method.
public class HomeController : ApiController
{
[System.Web.Http.ActionName("GetByString")]
public IEnumerable<File834Dto> Get(string subscriberNumber)
{
var someObj = SearchResults.SearchBySubscriberNumber(subscriberNumber);
return (someObj != null) ? someObj.FileResults : null;
}
}
And here is my HTML, I want to bind the results to the divSearchResult listbox, any sort of help would be very helpful, I am little bit new to the front end world, thanks in advance.
@{
ViewBag.Title = "Home Page";
}
<script src="~/Scripts/Search/search.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Home Page</title>
</head>
<body style="position: absolute; height: 98%;min-height:98%;width:85%;min-width:85%;">
<div style="position: absolute; height: 90%;min-height:90%;width:95%;min-width:95%;">
<div style="position: absolute; height: 90%;min-height:90%;width:95%;min-width:95%;">
<div id="divSearchResult" style="height: 90%;min-height:90%;width:95%;min-width:95%;">
<select name="cars" multiple="multiple" style="position: absolute; top:5%;">
<option value="volvo">Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
<label style="position: absolute; left:400px; top :5%;">Test</label>
<select name="cars" multiple="multiple" style="position: absolute; left:400px; top :10%;">
<option value="volvo">Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
</div>
<div id="divSearch">
<p>
<input type="text" name="txtSubscriberIdOrName">
</p>
<p>
<button style="width: 150px; border-radius: 5px; background: url('../../Content/Images/search-icon-psd-png.jpg'); background-size: 25%, 25%, 25%;background-repeat: no-repeat;"
id="search_report">
Search
</button>
</p>
</div>
<div id="message"></div>
<div>
Compiler: <input id="compiler" value="TypeScript" onkeyup="document.getElementById('message').innerText = sayHello()" /><br />
Framework: <input id="framework" value="ASP.NET" onkeyup="document.getElementById('message').innerText = sayHello()" />
</div>
</div>
</div>
</body>
</html>
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 3-Jan-17 16:35pm.
|
|
|
|
|
In an MVC Details view, it displays the field names down the left side using dt tags and it displays the data down the right side using dd tags.
My issue is that a few of my field names are longer than the room that is provided, so the last word or two of the column header drops down to the next line. How can I expand the available width for the field names column?
I have tried using CSS to set the Width and Column-Width properties of the dt tags. Neither one has any effect.
modified 24-Dec-16 2:06am.
|
|
|
|
|
Instead of that, why won't you chop the last words off?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I'm creating a web application for a hospital and they have all these columns with very specific meanings. I decided to just copy everything into a simple table. That should work. ![Java | [Coffee]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/coffee.gif)
|
|
|
|
|
No, I mean keep everything, just present everything in a good nature. Either keep the entire column to same size, let the content hide, or use adaptive approach (which is, the one you are facing right now), or strop down extra words, show only 4-5 and write "..." infront.
You can still have all the content in database, but just present it in a cleaner way.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Assuming you're using Bootstrap's horizontal description list[^], you just need a couple of rules:
.dl-horizontal dt {
width: 200px;
}
.dl-horizontal dd {
margin-left: 220px;
}
This will affect all horizontal description lists. If you only want to change specific lists, you'll need to add a new CSS class to identify them.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I've an application that displays information in a gridview:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" Font-Size="X-Small" OnRowDataBound="GridView1_RowDataBound"
PageSize="100" DataSourceID="SiteDataSource1" Width="100%">
<PagerSettings Mode="NumericFirstLast" PageButtonCount="20" Position="TopAndBottom" />
<RowStyle CssClass="itemstyle" />
<HeaderStyle CssClass="headerstyle" />
<AlternatingRowStyle CssClass="altstyle" />
<Columns>
<asp:BoundField DataField="Description" HeaderText="Description" ReadOnly="True" SortExpression="Description">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Identifier" HeaderText="Identifier" ReadOnly="True" SortExpression="Identifier">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="State" HeaderText="State" ReadOnly="True" SortExpression="State">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="HostHeaderValue" HeaderText="Host Header Value" ReadOnly="True"
SortExpression="HostHeaderValue" />
<asp:BoundField DataField="IPAddress" HeaderText="IP Address" ReadOnly="True" SortExpression="IPAddress" />
<asp:BoundField DataField="Port" HeaderText="Port" ReadOnly="True" SortExpression="Port" />
<asp:BoundField DataField="SSLPort" HeaderText="SSL Port" ReadOnly="True" SortExpression="SSLPort" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="false" CommandName="Control"
OnClick="Button_Clicked" Text="Control" Width="50" />
</ItemTemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
</Columns>
the status of the button is set
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView entry = e.Row.DataItem as DataRowView;
if (entry != null)
{
switch (entry["State"] as string)
{
case "Stopped":
e.Row.Cells[2].BackColor = System.Drawing.Color.OrangeRed;
e.Row.Cells[2].ForeColor = System.Drawing.Color.White;
((Button)e.Row.Cells[7].Controls[1]).Text = "Start";
((Button)e.Row.Cells[7].Controls[1]).ForeColor = System.Drawing.Color.Green;
((Button)e.Row.Cells[7].Controls[1]).CommandArgument = entry["Site"] as string + "|" + entry["Description"] as string;
break;
case "Running":
e.Row.Cells[2].BackColor = System.Drawing.Color.Honeydew;
((Button)e.Row.Cells[7].Controls[1]).Text = "Stop";
((Button)e.Row.Cells[7].Controls[1]).ForeColor = System.Drawing.Color.Red;
((Button)e.Row.Cells[7].Controls[1]).CommandArgument = entry["Site"] as string + "|" + entry["Description"] as string;
break;
default:
e.Row.Cells[2].BackColor = System.Drawing.Color.Yellow;
e.Row.Cells[7].Text = "";
break;
}
on a Windows 2008 server the button displays with no issues, however when I view this page with the gridview the column with the button is empty on a Windows 2012 server. Has anyone seen this before? Any help/advice greatly appreciated.
|
|
|
|
|
Did you try to look into, why it was empty?
Your server's variables are not shown to us and we cannot debug it without enough information.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
besides debugging the application and stepping through the code that sets the buttons values what else can I do?
In my test the code is hitting this case within the switch:
case "Stopped":
e.Row.Cells[2].BackColor = System.Drawing.Color.OrangeRed;
e.Row.Cells[2].ForeColor = System.Drawing.Color.White;
((Button)e.Row.Cells[7].Controls[1]).Text = "Start";
((Button)e.Row.Cells[7].Controls[1]).ForeColor = System.Drawing.Color.Green;
((Button)e.Row.Cells[7].Controls[1]).CommandArgument = entry["Site"] as string + "|" + entry["Description"] as string;
break;
but when to code has finished running and the webpage is displayed, here's the source of the webpage:
<tr class="headerstyle">
<th scope="col"><a href="javascript:__doPostBack('UcSites1$GridView1','Sort$Description')">Description</a></th><th scope="col"><a href="javascript:__doPostBack('UcSites1$GridView1','Sort$Identifier')">Identifier</a></th><th scope="col"><a href="javascript:__doPostBack('UcSites1$GridView1','Sort$State')">State</a></th><th scope="col"><a href="javascript:__doPostBack('UcSites1$GridView1','Sort$HostHeaderValue')">Host Header Value</a></th><th scope="col"><a href="javascript:__doPostBack('UcSites1$GridView1','Sort$IPAddress')">IP Address</a></th><th scope="col"><a href="javascript:__doPostBack('UcSites1$GridView1','Sort$Port')">Port</a></th><th scope="col"><a href="javascript:__doPostBack('UcSites1$GridView1','Sort$SSLPort')">SSL Port</a></th><th scope="col">Button</th>
</tr><tr class="itemstyle">
<td style="white-space:nowrap;">Default Web Site</td><td style="white-space:nowrap;">1</td><td style="color:White;background-color:OrangeRed;white-space:nowrap;">Stopped</td><td> </td><td> </td><td>80</td><td> </td><td style="width:50px;">
</td>
</tr>
You can see the cell[2] is updated with an OrangeRed background and white text. I've followed the code the whole way through and there is no where else it is manipulated, very strange.
What this application does is it reviews the status of Sites setup in IIS and displays their status in the gridview and if the site status = stopped the button should display 'start' and so on.
|
|
|
|
|
pmcm wrote: the column with the button is empty If the column is empty that means you have code somewhere that is hiding the button, .Visible = false; or some other code that is messing something up.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
turns out there was a database query that runs to validate the server is in an admin group after the button is set, atm the query is returning null so this is why the button is being disabled. Thanks for all the advice/help
|
|
|
|
|
Glad to see that you narrowed it down.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi all,
I have an Application that's using WPF, in which I have a ListBox as below, can I have similar kind of ListBox in HTML5 or can we have at least any other similar Control so that I can give same look and feel to the Customers that are using the Application. Any help is going to be very helpful, a code snippet a link or even a suggestion would be greatly helpful.
In the below xaml if you can replace < with < and > with > symbols it works. Is there any online tool to convert from xaml to HTML5 instead of downloading the application, because my company has download restrictions in the environment.
Here is the ListBox look like xaml:
<ListBox
Name="Members"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="166,80,0,0"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Top"
ItemsSource="{Binding ElementName=SubscriberResults, Path=SelectedItem.Members}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel
Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel
VerticalAlignment="Top">
<TextBlock
VerticalAlignment="Top"
HorizontalAlignment="Left"
Text="{Binding Path=Name}"
Style="{StaticResource DataLabel}"/>
<TextBox
VerticalAlignment="Top"
HorizontalAlignment="Left"
Text="{Binding Path=SSN}"
FontSize="12"
BorderBrush="Transparent"
/>
<TextBlock
VerticalAlignment="Top"<br />
HorizontalAlignment="Left"
Text="{Binding Path=DOB, StringFormat=d}"
Style="{StaticResource DataLabel}"/>
<ListBox
ItemsSource="{Binding Path=MemberDetails}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox
Text="{Binding Path=TranslatedDetail}">
<TextBox.Style>
<Style
TargetType="TextBox"
BasedOn="{StaticResource DataBox}">
<Style.Triggers>
<DataTrigger
Binding="{Binding Path=HasParsedData}"
Value="True">
<Setter
Property="FontWeight"
Value="Bold" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Click="Enroll_Click">
Enroll
</Button>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 20-Dec-16 17:37pm.
|
|
|
|
|
WPF and HTML5 both are different technology, you can not directly convert XAML to HTML5, instead you need to search for a control that will work like a wpf list box, and for UI look you can create a CSS in HTML5
I think HTML5 <datalist> Element, will help you more. Here is listbox link
Html5 ListBox - JSFiddle[^]
Find More .Net development tips at : .NET Tips
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
Hello,
I know that ASMX technology is considered legacy stuff. There's no need to lecture me on that point.
I am jumping in on an existing project that uses web services. (Editorial statement: Yuck!) When I test the webservice, I call up a similar URL to this:
https://OurServerVisibleToThePublic.com/FolderWithASMXFile/TheASMXFile.asmx
When I do this I get a page that contains all of the webservices we have defined. When testing, I click on one of them, a new page opens with parameters, I give it credentials and the XML that I am expecting is returned.
Now, I am attempting to call one or more web services from an ASP.NET application. The code looks like:
DIM WS as new CompanyWebServices.WebServicesClassName
GetData.DataSource = WS.MyWebServiceName(param1, param2, param3)
Unfortunately, the second line bombs, producing this fun error to solve:
Error: Server did not recognize the value of HTTP Header SOAPAction
At the top of the WSDL file, I have an attribute with a TargetNameSpace. The current setting is similar to this:
targetNamespace="https://OurServerVisibleToThePublic.com/FolderWithASMXFile"
When the app encounters the second line (i.e., WS.MyWebServiceName) I generate this error:
Message=System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: https://OurServerVisibleToThePublic.com/FolderWithASMXFile/MyWebServiceName.
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
* * * *
Does anyone know what I should specify in my TargetNameSpace? Does anyone actually like to troubleshoot web services? Thanks.
-- modified 20-Dec-16 16:11pm.
|
|
|
|
|
Take a look at the thread below called ASMX
21st Century Globalism has become Socialism on a planetary scale, in which the unequal treaties of the past have come back into play.
|
|
|
|
|
Thanks for the response. However, I don't see the answer to my question in the two other threads about ASMX.
|
|
|
|
|
I guess you missed it.
Making a call to your asmx is no different than say making a call to a PayPal or FedEx WSDL Service.
One way to do it is by creating a service reference off the asmx file. After you do that, then you will get a set of SOAP Class calls to call the asmx functions in the asmx file. Now you need to package a SOAP call, and send it by using a HTTP bind with a service endpoint. The service reference you created will create the SOAP headers automatically and make the request, and return the response, in which you unpackage and process.
In essence, your creating a WSDL service from scratch, and writing or creating the structure needed just like a PayPal or FedEx SOAP service for your own internal use.
The post below contains all of the parts needed to do this in vb, you'll just have to pick it apart and create a simple sample to get started, and from there you can get more elaborate with it.
21st Century Globalism has become Socialism on a planetary scale, in which the unequal treaties of the past have come back into play.
|
|
|
|
|
Hi jkirkerx, thanks for taking the time to contribute to our understanding of SOAP technology. However, I am trying to resolve an error. I perceive the source of the error to be the namespace that I am using in my WSDL file. I am trying to figure out how to move beyond the error by modifying the WSDL so that I know longer receive "Server did not recognize the value of HTTP Header SOAPAction."
You write: "One way to do it is by creating a service reference off the asmx file." That is not specific. This is what I said:
<me>
When I test the webservice, I call up a similar URL to this:
https://OurServerVisibleToThePublic.com/FolderWithASMXFile/TheASMXFile.asmx
...
Now, I am attempting to call one or more web services from an ASP.NET application. The code looks like:
DIM WS as new CompanyWebServices.WebServicesClassName
GetData.DataSource = WS.MyWebServiceName(param1, param2, param3)
...
At the top of the WSDL file, I have an attribute with a TargetNameSpace. The current setting is similar to this:
targetNamespace="https://OurServerVisibleToThePublic.com/FolderWithASMXFile"
</me>
I am trying to get help in specifying the targetNamespace. Thanks for your help so far, but I still don't have the answer to what I need.
Thanks,

-- modified 22-Dec-16 8:47am.
|
|
|
|
|
I am trying to populate the fields on a form from the database and the values aren't populating on the form. I have the value for the where clause hard coded in the code and it doesn't show the values that are in the database for that record on the form:
protected void Page_Load(object sender, EventArgs e)
{
this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
{
labelRID.Text = Request.QueryString["id"];
string rid = labelRID.Text;
string activityid = labelactivityid.Text;
if (!IsPostBack)
{
Bindactivitycodedropdown();
if (rid != "")
{
OracleConnection conn = new OracleConnection();
OracleCommand cmd = new OracleCommand();
conn.ConnectionString = strConnection;
conn.Open();
cmd.Connection = conn;
cmd.CommandText = "Select RID, BUYING_ACTIVITY_ID, CUSTOMER_SOURCE_CODE, CUSTOMER_NAME, CUSTOMER_CITY, CUSTOMER_STATE, CUSTOMER_POSTAL_CODE, BUYING_ACTIVITY_CODE from BUYING_ACTIVITY WHERE RID = '55555'";
cmd.Parameters.Add(new OracleParameter("RID", Request.QueryString["ID"]));
OracleDataAdapter da = new OracleDataAdapter(cmd);
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
labelRID.Text = dr["rid"].ToString();
custname.Text = dr["customer_name"].ToString();
custcity.Text = dr["customer_city"].ToString();
custstate.Text = dr["customer_state"].ToString();
custpostalcode.Text = dr["customer_postal_code"].ToString();
activitycode.SelectedItem.Text = dr["buying_activity_code"].ToString();
custsrccode.Text = dr["customer_source_code"].ToString();
cvactivitycode.Enabled = false;
dr.Close();
conn.Close();
}
else
{
labelRID.Text = "";
custname.Text = "";
custcity.Text = "";
custstate.Text = "";
custpostalcode.Text = "";
activitycode.SelectedItem.Text = "";
custsrccode.Text = "C812 - NASA";
}
}
}
}
}
|
|
|
|
|
Bootzilla33 wrote:
activitycode.SelectedItem.Text = dr["buying_activity_code"].ToString();
...
activitycode.SelectedItem.Text = "";
You're still changing the text of the first item in the list, rather than selecting the correct item.
As I keep telling you, you need to set the SelectedValue property on the list, not the Text property on the SelectedItem .
activitycode.SelectedValue = dr["buying_activity_code"].ToString();
...
activitycode.SelectedValue = "";
If the other values are not populating, then there is no matching record in the database. If you think there is, then you're not looking at the same database as your code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I am trying to pass data from controller to view and tried all the three options ViewData, Viewbag and tempdata but none of them are working. When I am debugging, I can see the value but it is not displaying
Here is my code snippet:
[HttpPost]
public ActionResult AllProducts(int zip)
{
ViewBag.Message = "Welcome";
ViewData["Test"] = "Welcom to Test";
TempData["Testing"] = "Welcome to Testing";
return View("AllProducts");
}
This is a @ViewBag.Message
This is a @ViewData["Test"]
This is a @TempData["Testing"]
Output:
This is a
This is a
This is a
Can someone please tell me what am I doing wrong. Thanks in advance.
|
|
|
|
|
Are you sure you're accessing the correct action? The action you've shown will only respond to a POST request, so if you're just navigating to the URL in the browser, you'll be running a different action.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You are right, I have two action AllProducts() and [HttpPost]AllProducts(int zip)
What I am trying to do here is I am passing the zip parameter from json
[HttpPost]
public ActionResult AllProducts(int zip)
{
TempData["zipcode"] = zip;
TempData.Keep("zipcode");
return RedirectToAction("AllProducts");
}
and trying to display zip code in AllProduct view by passing it to AllProducts()
blic ActionResult AllProducts()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
if (TempData["zipcode"] == null)
{
return View();
}
else
{
var code = TempData["zipcode"];
ViewBag.codezip = code;
return View();
}
}
I am newbie to MVC and not sure why is displaying ViewBag.Message and not ViewBag.codezip
What is that I am doing wrong. Please help me out.
|
|
|
|
|
Try simplifying your GET method:
public ActionResult AllProducts()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
ViewBag.codezip = TempData["zipcode"];
return View();
}
Also make sure that you match the case when you reference the value from your view:
Zip code: @ViewBag.codezip
You shouldn't need the TempData.Keep call in your POST action, since you don't read the value until the next request.
If it still doesn't work, then there must be something else going on that we can't see.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|