|
You just have to write the code. Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Yes, this subject has been covered in may post on may sites. Still, I con't get it to work 100%.
The project: Creating a dashboard with all my hardware configured.
Part of the process, is to add the devices to a SQL database.
My Dashboard.aspx is using a Masterage and the add device form is a ModalPopup.
Since systems can have more than one NIC, and more than one IP Address, I would like to have a ipv4multiselectdropdownlist.
As I said, I looked around a lot and it appears that a good way is to use a ListBox with the Bootstap plugin[^]
The result is:
<asp:panel id="AddDeviceModalPanel" style="display: none" runat="server">
<div class="HellowWorldPopup">
<div class="PopupHeader" id="PopupHeader"><asp:label runat="server" ID="ppheader" Text="Add a device" /></div>
<div class="PopupBody">
<asp:Label runat="server" ID="ppid" Visible="false" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<script type="text/javascript">
Sys.Application.add_load(BindEvents);
</script>
<table id="NewDeviceTable" runat="server">
<tr id="ipv4row" runat="server">
<td><asp:label id="ipv4lbl" runat="server" Text="IPv4" /></td>
<td>
<asp:ListBox ID="ipv4multiselection" runat="server" SelectionMode="Multiple" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="center">
<asp:button runat="server" id="AddDevicebtnSave" text="Save" />
<asp:button runat="server" id="AddDevicebtnCancel" text="Cancel" />
</div>
<div>
<asp:Label runat="server" ID="ppstatus" ForeColor="Red" />
</div>
</div>
</asp:panel>
<asp:HiddenField ID="hidForAddDeviceModel" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="add_device_popup" runat="server" TargetControlID="hidForAddDeviceModel" PopupControlID="AddDeviceModalPanel" BackgroundCssClass="ModalPopupBG" />
Next, I keep the selection in the desired order and get the values using the[^]
<script type="text/javascript">
function BindEvents() {
var orderCount = 0;
$('[id*=ipv4multiselection]').multiselect({
includeSelectAllOption: false,
maxHeight: 200,
numberDisplayed: 2,
onChange: function (option, checked) {
if (checked) {
orderCount++;
$(option).data('order', orderCount);
}
else {
$(option).data('order', '');
}
},
buttonText: function (options) {
if (options.length === 0) {
return 'None selected';
}
else if (options.length > 3) {
return options.length + ' selected';
}
else {
var selected = [];
options.each(function () {
selected.push([$(this).text(), $(this).data('order')]);
});
selected.sort(function (a, b) {
return a[1] - b[1];
});
var text = '';
for (var i = 0; i < selected.length; i++) {
text += selected[i][0] + ', ';
}
return text.substr(0, text.length - 2);
}
},
onDropdownHidden: function (event) {
var selected = [];
$('[id*=ipv4multiselection] option:selected').each(function () {
selected.push([$(this).val(), $(this).data('order')]);
});
selected.sort(function (a, b) {
return a[1] - b[1];
});
var text = '';
for (var i = 0; i < selected.length; i++) {
text += selected[i][0] + ', ';
}
text = text.substring(0, text.length - 2);
alert(text);
}
});
}
</script>
So far, everything is working.
At some stage though, I need that IP address selection.
I was thinking that assigning the text (i.e. selection) to a label and then use the label.text in the code would work but the label never get's the value assigned
text = text.substring(0, text.length - 2);
document.getElementById("Label1").innerHTML = text;
alert(text);
}
});
}
Again, poking around, a possible solution is to use a session variable.
So, modified the above code to call a PageMethod:
text = text.substring(0, text.length - 2);
ipv4sesssionvar(text);
alert(text);
}
});
}
and, in the code behind:
<System.Web.Services.WebMethod()> Public Function ipv4sesssionvar(ByVal txt As String) As String
Session("ipv4") = txt
ipv4sesssionvar = txt
End Function
Whenever <system.web.services.webmethod()> Public Function ipv4sesssionvar(ByVal txt As String) As String is called, I'm getting a Javascript error:
JavaScript runtime error: 'PageMethods' is undefined
My Script manager has to be on the master page and is believed to be setup correctly:
<asp:scriptmanager id="ScriptManager1" runat="server" enablepagemethods="true">
I saw suggestions to disable the Optimization. Done to no avail.http://stackoverflow.com/questions/21091935/webmethod-not-called-triggered-by-pagemethod-in-visual-studio-2013[^]
Saw that Javascript modification suggestionhttp://forums.asp.net/t/1886251.aspx?Microsoft+JScript+runtime+error+PageMethods+is+undefined[^] so now, my bottom Javascript looks like this:
text = text.substring(0, text.length - 2);
ipv4sesssionvar(text);
}
});
}
function ipv4sesssionvar(text) {
PageMethods.ipv4sesssionvar(text, OnComplete);
return false;
}
function OnComplete(result) {
alert(result);
}
I'm now at a stage where I'm stuck.
So, my question is: Can anyone please unstuck me?
Alternatively: Is there really no simple way to get this all done server side? A user control or something??????
Thanks.
modified 31-Aug-15 13:45pm.
|
|
|
|
|
I've a problem deploying a modified project based on ASP.NET in Visual Studio 2013.
I've one web page built on a ASP.NET project by a former engineer. It runs on a server with the *.dll file and other types of files (*.aspx, etc).
I have the source code of the project. I made a small change to the source code. It tests out fine on my local machine. However, when I build/publish the project the project doesn't output the *.dll file. It does output a bunch of other files including the *.aspx, *.aspx.cs, and *.sln files. But I need the new *.dll file to replace the old *.dll file on the server so that the web page can be updated.
I did some look-around online. A lot of people are saying that there are two types of ASP.NET projects: websites & web applications. And only web applications will output *.dll files. Websites don't use *.dll files.
If that is the case, that means my source code is a website project but the web page running on the server was built from a web application. But I know there is only one copy of the source code and the web page running on the server has to be generated from it.
|
|
|
|
|
Where is the project, what type is it?
If it's in the Web Project and the Code is in the App_Code folder, then the DLL is self building
If it's a separate project, then the DLL is in the BIN folder of the project under Debug or Release.
When you build the DLL, in the Build pane at the bottom of VS, it tells you where the DLL was built to.
|
|
|
|
|
Let me explain to you, the basic different of these types in the terms of frameworks. An ASP.NET web site is usually the ASP.NET Web Pages framework, that was compact and best for creating small web sites such as personal blogs or contact-me pages. Where as, web applications needed more of these things, URL routing, security and other stuff such as source management also, so there were other frameworks built (Web Forms is old, and ASP.NET has left it as of ASP.NET 5) and the framework ASP.NET MVC is mostly what people refer to.
Now, if you require those .dll files, consider uploading the entire package. Visual Studio 2013 doesn't prevent you from doing so. I recently published a new site of mine using Visual Studio 2013 to a server using their Web Deploy services. Visual Studio automatically does everything, plus if you want to replace the old .dll files. Do not do that manually. You may screw things up, I would recommend that you check "Remove files already present" so that Visual Studio can set up the stuff for you and then publish the app || website.
All of the ASP.NET code is generated as HTML page and content, these are only languages and syntax for building dynamic pages. Nothing else. What services are you using? Web Deploy or FTP or what? It depends on what service you use, as to publish the content also.
In all cases, you still get to upload the .dll files. You should, and frankly even in Web Pages framework (to what others refer as website) you need to publish the .dll files required, most aren't required because if they were it would have killed the purpose of compact. But if you have to add a library, you can add it, in the /bin/ folder.
So, finally, I will recommend that you try to publish the site as a new. Do back up your content before you remove the previous content from server.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Under the "Publish Web" Window that appears when you click on "Publish Web App", Go to the settings tab, expand "File Publish Options", Tick the "Precompile during publish" check box.
Please note that you need to publish all apsx files and dll's, because the reference to the dll in the aspx file change with every publish.
Hope this helps.
|
|
|
|
|
Thank you. Your response has most directly helped me out
|
|
|
|
|
Hello,
I have a TextArea, A submit button and a check box on a Razor view, i want to load some records from the database in to the textarea and then use the submit to send Mesages to the recods loaded.
The issue is that i dont know how to load the data using the check box.
This is my code so far:
the controller:
public ActionResult Message(bool loadData)
{
List<sendmessageviewmodel> _mobile = new List<sendmessageviewmodel>();
if (loadData)
{
foreach (var item in db.ParentsModels)
{
_mobile.Add(new SendMessageViewModel { destination = item.mobile+"," });
}
}
return View(_mobile);
}
The View code is:
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
}
Thanks
|
|
|
|
|
Try searching Google using these words "mvc razor, checkbox event"
@Html.Checkbox( "somename", new { @onclick="function-to-open-dialog()"})
|
|
|
|
|
We have a message for you. But we hid it.
Unless you know the secret phrase, it will remain hidden.
Can you write the algorithm to find it?
Here is a couple of important hints to help you out:
- An anagram of the phrase is: "poultry outwits ants"
- The MD5 hash of the secret phrase is "4624d200580677270a54ccff86b9610e"
|
|
|
|
|
We STILL don't do your homework, no matter how many times you re-post it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
thank you for your reply but i need guideline no need to do this task for me just tips
|
|
|
|
|
<asp:datalist id="DataList1" runat="server" repeatcolumns="2" width="50px"
="" onitemdatabound="DataList1_ItemDataBound" datakeyfield="Category">
<itemtemplate>
<%# Eval("Category")%>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FirstFillDatalist();
}
}
DataTable set = new DataTable();
private void FirstFillDatalist()
{
adapter = new SqlDataAdapter("select * from category", con);
adapter.Fill(set);
DataList1.DataSource = set;
DataList1.DataBind();
}
data show..now go to next page with click any where means tag
it is Default.aspx page
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" Width="150px"
DataKeyField="sub_category" >
<ItemTemplate>
<%# Eval("sub_category")%>
Default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
FirstFillDatalist();
}
private void FirstFillDatalist()
{
adapter = new SqlDataAdapter("select * from sub_category where cate_id=5", con);
DataTable set = new DataTable();
adapter.Fill(set);
DataList1.DataSource = set;
DataList1.DataBind();
}
then show only cate_id=5 value and i want to be dynamic change of "select * from sub_category where cate_id=5" cate_id value....
|
|
|
|
|
what exactly is your question?
I look at your markup and code, but I can't tell if it works or not, and where it fails.
Why not just post code for the part that fails to work? and tell us what's not working.
|
|
|
|
|
Hi.
I run a ASP.NET web site.This web site need authentication people with Microsoft ActiveDirectory.Threr are more than 500 thousand user ,10 thousand OrganizationUnit on the Domain Controller.
I wrote a function to validate people in a static class:
Hide Copy Code
static public string ValidateCredentials(string userName, string password)
{
string result = null;
try
{
log4net.ILog log = log4net.LogManager.GetLogger("Login.Aspx");
DateTime time0 = DateTime.Now;
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, StsDomainName, StsAdRootOu + "," + StsDomainDn , ContextOptions.SimpleBind,StsAdUserName, StsAdUserPswd);
if (principalContext.ValidateCredentials(StsDomainShrotName +"\\" + userName, password,ContextOptions.SimpleBind))
result = "1";
else
result = "0";
log.Debug("Time cost:" + (DateTime.Now - time0).TotalMilliseconds + "DC:" + principalContext.ConnectedServer);
}
catch (Exception e)
{
result = e.Message;
}
return result;
During hign concurrency scence, more than 2000 user login the web site at the same time. I found it cost a long time to do the validation.
But if i dim the principalContext as a static member of the class,the time cost on validation will be cut down.But the CPU usage on the web site server will raise to 90%.
anyone can help me to improve my code
|
|
|
|
|
I am new to MVC framework and trying to learn the tricks and I am stuck in one small issue.
Since I have multiple enumerators in the project I have two tables which store them.
One table stores the type of enumerator such as
EnumeratorId int
EnumeratorName varchar(50)
The second table stores the values of the enumerator such as
EnumeratorTypeId int
EnumeratorType varchar(50)
EnumeratorId Int
Since I have to use multiple enumerators in my screen i am planning to write a user control or what they call as partial view. But I am not sure how to bind them to the model or how to write the partial view.
Can anybody help me ??
Rajesh.M
|
|
|
|
|
There is a requirement in my Project to show a PDF file to the user which is there on the Network shared drive. I have a trouble to set path of the file to the PDF.js.
Th path of my PDF file will be like this. \\dpk020\workingfolder\document.pdf
Could anyone who already used the PDF.js in MVC project help me to resolve this.
Regards,
Rajesh
|
|
|
|
|
Code running on a website cannot access local files on the client. If it could, that would be a major security vulnerability.
To display a file on your website, the file will need to be available from a web URL (http://... or https://... ). Due to cross-domain request limitations, that URL will need to be part of the same site. If it's on a different domain, you will need to enable CORS[^] on the domain which hosts the file.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hai Homer,
Thanks for the reply. My PDF Files are dynamic. There is a WCF service which generates those files and send back the file paths. These files are stored on shared drives on local network. So having said that, do you think I cannot use PDF.js to View PDfs on my webpages?
Thanks,
Rajesh
|
|
|
|
|
You'll need to create an action in your site to send the file to the browser, and set the PDF.js file URL to point to that action.
The answer from sigma_ivan[^] looks like a good place to start.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Code to return file in MVC found it here http://www.mikesdotnetting.com/article/125/asp-net-mvc-uploading-and-downloading-files[^]
you can choose whatever type of file it is. as long as you put the right format/contentType in your case "application/PDF"
public FileStreamResult StreamFileFromDisk()
{
string path = AppDomain.CurrentDomain.BaseDirectory + "uploads/";
string fileName = "test.txt";
return File(new FileStream(path + fileName, FileMode.Open), "text/plain", fileName);
}
IMO
|
|
|
|
|
Today I asked an interview question. Can you please anyone help me. Question is...
I am having 3 database connections. SQL, Oracle and DB2. In SQL i am going to update.
In Oracel I am going to insert.
In DB2 I am going to delete.
If anyone operation fails, all need to rollback. How to achieve this, either in .NET or DB side.
Expecting your help.
Thanks,
Karan
|
|
|
|
|
Use a Distributed Transaction Coordinator (DTC).
|
|
|
|
|
<asp:datalist id="DataList1" runat="server" repeatcolumns="2" width="50px"
="" datakeyfield="category" enableviewstate="False" onitemdatabound="DataList1_ItemDataBound">
<itemtemplate>
<%# Eval("category") %>
category country that is first page use. select country go to next page and change id again select state same as city..
|
|
|
|
|
|