|
I have a table that uses Ajax to load. It is basically set up like this:
@using (Ajax.BeginForm(ajaxOpts))
{
<table>
<thead>
<th>column 1</th>
<th>column 2</th>
</thead>
<tbody>
@Html.Action("List")
</tbody>
</table>
}
In each row that is returned is a button that I have created a jquery event. It opens a dialog that displays some addition details about the record.
$(".view-row-button").click(function () {
var $id = $(this).attr("id");
$("#details-dialog")
.load('@Url.Action("action", "controller")' + '?record=' + $id)
.dialog({
modal: true,
height: 750,
width: 1200,
close: function () {
//refresh table
$("#refresh-button").click();
}
}).dialog("open");
});
The first time I click the row button, everything works great. The action is called and the details of the record are queried. The next time, the dialog is still displayed, but it is not updated with any changes I may have made. I put a breakpoint in the action, which catches on the first click, but not the next clicks. I've tried refreshing the page, but that still doesn't work. I have to re-open the browser to get the click to work properly again. Any suggestions?
|
|
|
|
|
It can be a problem of your browser which is not refreshing the page properly because especially IE is well-known for "not properly refreshing the cache". Try to do this:
- click the row button
- The action is called and the details of the record are queried.
Then delete the whole cache of the browser and click the row button again. If then everything is working fine, you know that it is a browser-problem which you can't solve.
|
|
|
|
|
That is exactly the problem. Thank you.
|
|
|
|
|
|
Thank you, I am glad that I was able to help you out.
|
|
|
|
|
Here is my code:
$('.Status').click(function() {
var divparent = $(this).closest('.tabs-content');
var ruleid = divparent.attr('data-ruleid');
var statusid;
if (divparent.hasClass('inactive')) {
$(this).closest('.tabs-content').removeClass('inactive');
statusid = 1;
}
else {
console.log('active');
$(this).closest('.tabs-content').addClass('inactive');
statusid = 0;
}
$.ajax({ type: "POST", Url: "NewRules.aspx/SaveStatus",
data: "{strStatus:'" + statusid + "',strRuleID:'" + ruleid + "'}",
contentType: "application/json;charset=utf-8",
dataType: "json"
});
});
and here is the WebMethod:
[WebMethod]
public static string SaveStatus(string strStatus,string strRuleID)
{
int status = int.Parse(strStatus);
long RuleID;
if (long.TryParse(strRuleID, out RuleID))
{
UploadScheduleDisplay display = UpSchDisp.Where(d => d.Id == RuleID).FirstOrDefault() as UploadScheduleDisplay;
if (display != null)
{
if (display.IsPaused)
{
display.Resume();
}
else
{
display.Pause();
}
CommandUtils.SendNewCommandAudit(CommandTypeEnum.ProgramUploadScheduleRules, 0, unitid,
1, 0, cmd_changeStatus, WebMethodLogin);
}
}
else
{
return "";
}
return RuleID.ToString() + " " +status.ToString();
</pre>
The Jquery click works, but it never goes to WebMethod, do you have any idea what is wrong with my code?
Thanks
modified 21-Mar-13 17:41pm.
|
|
|
|
|
Url: "NewRules.aspx/PostUser"
There is no postUser in the webmethod
|
|
|
|
|
I thought I changed it . thank you so much. this usually happens to me when I am working late.
|
|
|
|
|
Same here, 2nd set of eyes helps out
|
|
|
|
|
But with this
$('.Status').click(function() {
var divparent = $(this).closest('.tabs-content');
var ruleid = divparent.attr('data-ruleid');
var statusid;
if (divparent.hasClass('inactive')) {
$(this).closest('.tabs-content').removeClass('inactive');
statusid = 1;
}
else {
console.log('active');
$(this).closest('.tabs-content').addClass('inactive');
statusid = 0;
}
$.ajax({ type: "POST", Url: "NewRules.aspx/SaveStatus",
data: "{strStatus:'" + statusid + "',strRuleID:'" + ruleid + "'}",
contentType: "application/json;charset=utf-8",
dataType: "json"
});
This is not still workingggggggg!!!!!!!
pLEASE HELP
|
|
|
|
|
I don't reccomend trying to bind to a class
$('.Status').click(function() {
but to bind to the element ID instead
Plus you need to test your bind to make sure it works
There are several ways to bind
With update panel
$(document).ready(function () {
initiateBinding();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
});
function EndRequestHandler(sender, args) {
initiateBinding();
}
function initiateBinding() {
$(document).ajaxStart(function () {
});
$(document).ajaxStop(function () {
});
$('[id*="_ddl_RTSR_SARates_Unified_SelectRate"]').change(function () {
alert("I'm Alive");
});
}
with no update panel
$(document).ready(function() {
$('[id*="_ddl_RTSR_SARates_Unified_SelectRate"]').change(function () {
alert("I'm Alive");
});
});
So test the bind first, then move on to the function code and report back, I'm leaving in 30 minutes today
[edit]
test your data,
alert("{strStatus:'" + statusid + "',strRuleID:'" + ruleid + "'}");
copy the messagebox contents using firefox and paste it into the json validator to make sure it's valid json
http://jsonlint.com/[validator^]
you have to use slashes to escape out the double quotes
"{\"m_Rate_API_Code\" : \"" + rate_API_Code + "\"}"
Your JSON doesn't look valid to me {"name" : "Jim"}
modified 21-Mar-13 18:05pm.
|
|
|
|
|
the binding works, the console.log shows that. and the parameters are just numbers, what is wrong with them?>
The thing is the page is postback but the webmethod is not running, it only goes to pageload!
and One more thing! Sys is not a valid name when I tried to use it!! I don't know why!
|
|
|
|
|
You should call the web method page directly, and see if the debug interface comes up, enter your value and test it.
[edit]
on the Sys is not a valid name, the Sys exist if the button you binded is inside an update panel.
With out the example I provided, you will lose the bind when the panel updates,
if you don't have an update panel, then it's just the on ready function.
Without seeing the project, it's hard to say why the page is not firing, but most likely it an error in the page name or extension.
modified 22-Mar-13 14:22pm.
|
|
|
|
|
How do you debug a single ASPX file?
I am somewhat new to ASPX files, but I am not new to C#.
I figured that all asp.net c# projects were run on the server as compiled code. And so there was some sort of binary file somewhere somehow or maybe a XAP file like they have with silverlight.
But it seems that this is not the case. it seems that, sometimes, you can have an ASPX file along with the code-behing C Sharp file and it runs just like a PHP file. For starters, is that right? Am I right so far?
Now, if I was the owner of both the ASPX file and the CSHARP code-behind file, how would I go about debugging it in Visual Studio?
|
|
|
|
|
To the best of knowledge
You have the web form, which is HTML and combinations of asp.net objects, similar to a PHP page
and code behind forms, that you write code in. asp.net objects can link to code behind using handlers, that point the code to the web form object.
The objects in asp.net, can be used 2 ways, on the web form as a HTML type of element, or in code behind in pure code.
When you run your project, asp.net will compile your code as various DLL files, and store them on the c drive under windows\Microsoft asp.net.
To debug your project, you press F5 using Visual Studio, you have to load the page you want to debug first, and set a break point by pressing F9 on the line of code you want. I think you can only debug code behind pages.
|
|
|
|
|
the file is https://www.seattleu.edu/admission/nonMatricLander.aspx
and out on the server there is just the aspx file and the accompanying .cs file
that is all there is. There is no solution file, there is no default.aspx file there is nothing else in the that directory apart from other .aspx files and aspx.cs files.
If it was a web form, there would be a project file and and or a solution file. There would be something compiled, right? There is nothing like that. there are no dll files.
How do I run the code?
My point is that there is no project to load. There is only a file.
After setting a break point, there is nothing to run. I have tried attaching to the browser that has the aspx code loaded but then the breakpoints become inactive.
|
|
|
|
|
You can only debug a project or page that is on your hard drive, if the page you posted is crashing, then you have to look at the stack trace, and work your way down the list to find the line of code that bombed.
[edit]
are you trying to reverse engineer the page?, or seriously need to fix something?
modified 20-Mar-13 23:34pm.
|
|
|
|
|
I think I need to do this. I need to run the code locally through "localhost" and attach the process through the debugger. How do I run the localhost?
|
|
|
|
|
If the project is on your hard drive, and your using VS 2010, you press F5 on the page selected, and it will run on the localhost.
What are you trying to fix, is it a javscript issue, or asp.net code behind.
|
|
|
|
|
Hello folks,
I thought this would be very simple. but I am not able to.
I tried simple code like this using href element. But it tries to open the sheet.xls in the browser window and says it can't find the file. I want the excel file to be opened in excel (not browser). Any suggestions?
<a href="file://domainname/vol1/destinationfiles/sheet.xls" >some excel file</a>
The excel file I am trying to open is not on IIS server. It is on file server.
Thanks much
nath
.
|
|
|
|
|
Where do you expect the excel file to run? On the server side?
Remote launching of apps at the client end is possible, but I doubt that you can do this directly (see below) from web server code. Also presumes they have Office installed on the remote machine.
Remote execution needs to be enabled/allowed at the far end.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
Strange. I also thought it was easy.
But on my system, every call to a href="file:..." fails when the page containing the link was obtained via http.
Such links do work only when the page was opened with the file protocol. And the links do fail when the file to be opened is not on a local or mapped drive. Browsers offer to open the file (with Excel) when it is on a local/mapped drive or just download it.
I tested with current versions of Internet Explorer, Firefox, Chrome, Opera, and Safari.
|
|
|
|
|
Well I've never had to try it,
The web server would most likely need to generate a local script with *application name hard coded*, then execute via a shell COM object. The local script can then do some remote checking of its own, and then launch the remote application. (Windows Script Host)
That's how I would try to do it.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
After export gridview to excel using asp.net and vb.net
Save as Type:Web Page. I want it should be Microsoft Office excel workbook
My code like this
====================
gvRpt.AllowPaging = False
gvRpt.GridLines = GridLines.Both
Dim style As String = " .text { mso-number-format:\@; } </script> "
Response.ClearContent()
Response.Clear()
Response.Buffer = True
Response.Charset = ""
Me.EnableViewState = False
Response.AddHeader("content-disposition", "attachment;filename=" & RptName & ".xls")
Response.ContentType = "application/excel"
'Response.ContentType = "application/vnd.ms-excel"
Dim sw As New StringWriter()
Dim htw As New HtmlTextWriter(sw)
gvRpt.RenderControl(htw)
Response.Write(style)
Response.Write(sw.ToString())
Response.End()
|
|
|
|
|
try below code.
gvRpt.AllowPaging = False
gvRpt.GridLines = GridLines.Both
Dim style As String = "<style> .text { mso-number-format:\@; } </script> "
Response.ClearContent()
Response.Clear()
Response.Buffer = True
Response.Charset = ""
Me.EnableViewState = False
Response.AddHeader("content-disposition", "attachment;filename=" & RptName & ".xls")
Response.ContentType = "application/vnd.ms-excel"
Dim sw As New StringWriter()
Dim htw As New HtmlTextWriter(sw)
gvRpt.RenderControl(htw)
Response.Write(style)
Response.Write(htw.ToString())
Response.End()
hope it works.
Vande Matharam - Jai Hind
|
|
|
|