|
Hello,
We have a web application capturing the errors using the EventLog viewer on the machine it is hosted.
Does this method of capturing the error work well?
Any inputs on how to capture an apps errors?
Thanks!
|
|
|
|
|
What works best for you, or one situation, may not be the best for another. You could also use a custom event logger sucha Log4Net or EL Exception Handling Block
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I want that when i will enter the TextA i will see on the third table pic b (Winter)
and when i will enter TextB i will see on the third table pic c (Sunset)
Please help !!!
<%--When mouse will be over the text then i want the third table will show pic (Winter)--%>
<table width="100%" style="height:100px">
<tr>
<td onmouseover="showPic('Winter');" width="100%" style="height:100%">
ChangeToPicA -> The Text
</td>
</tr>
</table>
<%--When mouse will be over the text then i want the third table will show pic (Sunset)--%>
<table width="100%" style="height:100px">
<tr>
<td onmouseover="showPic('Sunset');" width="100%" style="height:100%">
ChangeToPicB -> The Text
</td>
</tr>
</table>
<%--The third table which need to change the pictures--%>
<table id="Sunset" class="pichide" width="100%" style="height:250px">
<tr>
<td width="100%" style="height:100%">
</td>
</tr>
</table>
JScript2.js
function showPic(id)
{
document.getElementById("Sunset").className = "c";
document.getElementById("Winter").className = "b";
document.getElementById(id).className = "picshow";
}
stylesheet.css
.c
{
background-image: url('Sunset.jpg');
background-repeat:no-repeat;
}
.b
{
background-image: url('Winter.jpg');
background-repeat:no-repeat;
}
.pichide
{
display: none;
}
.picshow
{
display: block;
border: 1px;
}
-- Modified Monday, August 1, 2011 9:18 AM
|
|
|
|
|
First, FORMAT your code snippets!!!
Creating tables for one cell is extreme overkill.
<span id="text1">Text A</span>
<span id="text2">Text B</span>
<img id="pic">
<style>
span, img
{
display:block;
}
</style>
<script>
$(document).ready(function()
{
$("#text1").hover(function()
{
$("#pic").attr("src", "Sunset.jpg");
});
$("#text2").hover(function()
{
$("#pic").attr("src", "Winter.jpg");
});
});
</script>
I know the language. I've read a book. - _Madmatt
modified on Monday, August 1, 2011 9:25 AM
|
|
|
|
|
i wrote the text which on mouseover it will make that changing
is in lines 9, 17
|
|
|
|
|
Hi,
I want to remove the extension of my asp.net webpages(I have a webapplication).
I've read some guidelines about the issue but I've found some simple ways to do it.
I've tried adding the following lines to my web.config file:
<rewrite>
<rules>
<clear />
<rule name="san aspx">
<!--Removes the .aspx extension for all pages.-->
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx" />
</rule>
</rules>
</rewrite>
I have also tried to add this function to Application_BeginRequest in my global.asax file:
string curruntpath = Request.Path.ToLower();
curruntpath = curruntpath.Trim();
if (curruntpath.EndsWith(".aspx"))
{
string finalurl = curruntpath.Substring(curruntpath.Length - 5, 5);
HttpContext.Current.RewritePath(finalurl);
}
In the first case, when I type "www.site.com/page" I'm being redirected to "www.site.com/page.aspx"(which is my wanted page), but when I type "www.site.com/page.aspx" I want the shown URL to be "www.site.com/page", and it doesn't happen.
In the second attempt I just can't get any page when typing "www.site.com/page.aspx".
What should I do in order to solve it?
|
|
|
|
|
Im using vs 2008 ( asp.net / vb.net )
I've got grid with editable textboxes on the rows ( 1 textbox per column ).
On focus of a textbox I need to have a postback to retrieve a related value and display it on screen but after the postback it loses the focus.
Is there anything i can do to keep the focus?? tried multiple things online but nothing working yet
if i manual set the focus back to the control, then it will just fire the onfocus event - and therefore enter a loop.
anyone got any ideas
|
|
|
|
|
In this case I would definitely use AJAX rather than postbacks. It will solve you control focus issue and give a better user experience.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
thanks, but even using ajax it still creates a postback doesnt it. on focus of the control i need it to run some vb.net code ( server side code ). I have ajax set up and it still loads the page_load event so i presume it is still posting back, no ?
eiher way i dont have it working with ajax, maybe i have set some thing wrong
my code is
in pageload event
TextBox1Test.Attributes.Add("onfocus", "javascript:DoPostBack('TextBox1Test');")
Dim eventTarget As String = Request.Form("__EVENTTARGET")
If eventTarget IsNot Nothing Then
DayPostback(eventTarget) // server side code i need to run on focus
End If
javascript code
function DoPostBack(control) {
__doPostBack(control, "onFocus");
}
if i set the DayPostback method to manually set the focus, i get in a loop, if I loop the textbox loses focus after the event has been fired
modified on Monday, August 1, 2011 7:36 PM
|
|
|
|
|
You are not using AJAX, even in the slightest, most liberal definiation. AJAX is an out of band call, there is no postback involved. You should spend some time reading up on AJAX and its usage if you want to be doing web development.
<asp:TextBox runat='server' id='myText' onblur="AjaxCall();"/>
<span id='myResults'/>
function AjaxCall()
{
$.ajax({
type: "POST",
url: "foo.aspx/Bar",
data: "text=" + $("[id$='myText']").text(),
success: onSuccess
});
}
function onSuccess(data)
{
$("#myResults).text(data);
}
[WebMethod()]
public static string Bar(string text)
{
// DO something
return "something";
}
ALso make note of code snippets are properly formatted. Now you try.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hey!
I know it is a common question but I am too close and cant find solution. I have two Pages between A.aspx and B.aspx.
When you fill your name and surname on the textbox controls and then click on send button, redicted to B Page to say thank you for ordering but if you want to fill the form again for another ordering, click on back button from B Page to go back to previous page (A Page) and details (your name and surname) should remain on textbox controls. So you dont need to write your name and surname again. How to do this?
A.aspx:
<label>Name:</label> <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<label>Surname:</label> <asp:TextBox ID="txtSurname" runat="server"></asp:TextBox>
<asp:Button ID="Send" runat="server" Text="Send Email" onclick="Send_Click" />
A.aspx.cs (C#):
protected void Send_Click(object sender, EventArgs e)
{
Response.Redirect("B.aspx");
}
B.aspx:
<p>Thank you for ordering. We will contact you very soon.</p>
<p>Do you want to order item again? Go back to A Page <asp:Button ID="btnBack" runat="server" Text="BACK" onclick="Send_Click" />
</div>
B.aspx.cs (C#):
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Request.UrlReferrer.ToString());
}
Problem: when i clicked on back button, redicted to A Page and all the details (name and surname) are gone from textbox control. I want these details to remain, dont need to write it again.
Your help will be highly appreciated. Thanks for your time :-)
|
|
|
|
|
The web is stateless, you must persist any data is so manner if you wish to use it again. A common method is to pass an id, either via query string or session state, and have the page lookup the appropriate data in a datastore as required.
Also, you only need to format the code snippets you post, not the entire message. Please edit your post and correct the formatting
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I'd store that information in a cookie.
|
|
|
|
|
Hey
I want to change a image that is in one td
when my mouse moving over a onther element like (text, another td, tr, table)
example :
<table> // the image that needed to be switch with another image
<tr>
<td>
<b><img src="ABC.jpg"/></b>
</td>
</tr>
</table>
<table>
<tr>
<td>
<b>TEXT</b>
</td>
</tr>
</table> // here i want to creat a mouseover/out option
please help
thank's
|
|
|
|
|
Hi,
using JQury can do the trick. First assign id to your table/image elements, for example
<table id="table1">
<tr>
<td>
<b><img id="img1" src="ABC.jpg"/></b>
</td>
</tr>
</table>
<table id="table2">
<tr>
<td>
<b>TEXT</b>
</td>
</tr>
</table>
Now use jquery
$("#table2").mouseover(function() {
$("#img1").attr("src","xyz.jpg");
}).mouseout(function(){
$("#img1").attr("src","abc.jpg");
});
Thus mouseover event triggers each time you hover table2 and change the image to xyz.jpg
you will get similar concept from here[^]
Hope this will help
|
|
|
|
|
I have JScript1.js
not JQury
I using Visual Basic 2008
Please help thank's
|
|
|
|
|
|
Hi,
I want to have Session in Global.asax file.
I had declared in global.asax.cs
like
void Application_Start(object sender, EventArgs e)
{
string strUser = HttpContext.Current.Session["USER_NAME"].ToString();
}
It says object reference not set.
I had tried by giving HttpContext.Current.User.ToString(),that also did not work out.
Also on Session End i want to end or Dispose the Session.
This Session variable must be accessible throughout the web application.
Please help.............
Thanks
S.Guhananth
|
|
|
|
|
Application_Startup is called when the application itself starts (or re-starts if it has stopped after going idle) and is unrelated to a particular user session, so is the user stuff in uninstantiated. This would be the method you'd call to log at what times the application starts and re-starts for example.
It looks very likely that you need is to move this code to the Session_Start method, this is called the first time a user starts a session. The current user object is available at this point, as is the Session property.
void Session_Start(object sender, EventArgs e)
{
string strUser = HttpContext.Current.Session["USER_NAME"].ToString();
}
If the user were available in application startup, only the user who started the application would have their username set!
|
|
|
|
|
Hey!
I have been trying several times to fix it but couldnt find correct codes in C#. You can copy all these below codes of markup and C# so that you will see what is problem. Im fine with markup but only problem with C#. There is some explanations (bold and underline) below. Your help will be highly appreciated. Thanks so much for your time Looking forward to hearing from you!
Markup:
<form id="Form1" method="post" runat="server">
<label><asp:TextBox ID="txtName" runat="server"></asp:TextBox>Name:</label>
<label><asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>Email Address:</label>
Order the following cards:
<asp:ListBox name="order" Runat="server" ID="dlist1" SelectionMode="Multiple" onchange="swapImage1()">
<asp:ListItem>SOW SEEDS OF LOVE</asp:ListItem>
<asp:ListItem data-card="R 32.00" data-memo="R 62.00" Value="Images/Bday.jpg">Birthday</asp:ListItem>
<asp:ListItem data-card="32.00" data-memo="62.00" Value="Images/Wedding.jpg">Wedding</asp:ListItem>
</asp:ListBox>
Display prices when clicked an item on listbox control:
<script type="text/javascript">
window.onload = function()
{
document.getElementById("dlist1").onchange = function() {
var option = this.options[this.selectedIndex];
document.getElementById("price_card").innerHTML = option.getAttribute("data-card") ? option.getAttribute("data-card") : "";
document.getElementById("price_memo").innerHTML = option.getAttribute("data-memo") ? option.getAttribute("data-memo") : "";
}
}
</script>
Display image when clicked an item on this ListBox control (above):
<div>
<asp:Image ID="imageToSwap1" runat="server" width="147" height="195" ImageUrl="" />
</div>
<script type="text/javascript">
function swapImage1() {
var image = document.getElementById('<%= imageToSwap1.ClientID %>');
var dropd = document.getElementById('<%= dlist1.ClientID %>');
image.src = dropd.value;
};
</script>
1) After choosing an item (birthday card) on ListBox control, then you decide to choose "card A6" on input control using checkbox but you also choose another item (wedding card) on ListBox control, so you also choose "memo book" (only for wedding card)
2) Look below (bold) -- id="price_card" and id="price_memo" are implemented by Javascript to display several price
<table>
<tr>
<td input type="checkbox" name="description" value="Card A6" id="description1" runat="server" /> Card A6 (blank)</td>
<td id="price_card"></td>
</tr>
<tr>
<td input type="checkbox" name="description" value="Memo Book A6" id="description2" runat="server" /> Memo book </td>
<td id="price_memo"></td>
</tr>
</table>
For example: if you wanna order two cards (card A6 for birthday card and memo book for wedding card), then clicking on send button to send this data to my gmail account:
<asp:Button ID="Send" runat="server" Text="Send Email" onclick="Send_Click1" />
</from>
I have no problem with this markup but have a little problem with codes (C#). After you sent order data to my gmail account, I will get your email and can read this data what you wanna order.
This order data should be displayed on email: (thats what I want)
Name: xxx
Email Address: xxx
Order 1: Images/Birthday.jpg
Description 1: Card 6
Order 2: Images/Wedding.jpg
Description 2: Memo Book
My current problem:
Name: xxx
Email Address: xxx
Order 1: Images/Birthday.jpg (no display)
Description 1: Card 6 (display) - fine
Order 2: Images/Wedding.jpg (no display)
Description 2: Memo Book (no display)
Im struggling with codes in C# - look at below and you can test these codes (copy) to receive your email on your gmail account after clicking on send button. You will see some order data is missing:
protected void Send_Click1(object sender, EventArgs e)
{
string msg = "---------------------------<br>";
string from = "youremail@gmail.com";
string to = "youremail@gmail.com";
MailMessage mail = new MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(from, "Ellie Rose", System.Text.Encoding.UTF8);
mail.Subject = "Customer Order from Ellie Rose Website";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
msg += "Name: " + txtName.Text;
msg += "<br>Email: " + txtEmail.Text;
if (description1.Checked == true) //Card A6 - need to display data on email - not working
{
msg += "<br>Description 1:" + description1.Value;
msg += "<br>ORDER 1: " + Request["order"];
}
if (description2.Checked == true) //Memo Book - need to display data on email - not working
{
msg += "<br>Description 2:" + description2.Value;
msg += "<br>ORDER 2 : " + Request["order"];
}
mail.Body = msg;
mail.BodyEncoding = System.Text.Encoding.ASCII;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
//Add the Creddentials- use your own email id and password
client.Credentials = new System.Net.NetworkCredential(from, "yourpassword");
client.Port = 587; // Gmail works on this port
client.Host = "smtp.gmail.com";
client.EnableSsl = true; //Gmail works on Server Secured Layer
try
{
client.Send(mail);
}
catch (Exception ex)
{
Exception ex2 = ex;
string errorMessage = string.Empty;
while (ex2 != null)
{
errorMessage += ex2.ToString();
ex2 = ex2.InnerException;
}
HttpContext.Current.Response.Write(errorMessage);
} // end try
}
|
|
|
|
|
No one is going to read this huge mess of unformatted garbage let alone copy it and run it for you.
Please review the posting guidelines and format any code snippets. Also, only post the relevant code, NOT ALL. And, fully describe your expected results, problems encountered and any attempts you have made.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
Anyone know how to convert ASP.NET code to HTML at runtime. like it do in the VS IDE(Source to Design).
when i entered some code like below to a text box and click a button
<asp:button id="Button1" runat="server" text="Button" onclick="Button1_Click">
it should convert it to html and render the button.
I simply need something like this (try it yourself in w3schools)
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_button[^]
instead of HTML code there I need to create a site in ASP.NET which user can input ASP.Net code and get the output
Thanks in advance
|
|
|
|
|
well;
your button is rendered as
<input type="submit" id="Buttun1.ClientID" name="Buttun1.UniqueID" value="Button" />
onclick="Button1_Click" has nothin to do with the client(HTML) it runs at server
if you add UseSubmitBehavior="false" to the button the render will be
<input type="button" id="Buttun1.ClientID" name="Buttun1.UniqueID" value="Button" onclick="javascript:__doPostBack('Buttun1.UniqueID','');" />
__doPostBack() function assigns its first parameter to the hidden field __EVENTTAARGET and the second to __EVENTARGUMENT and submit the form. In case ...etc.
this is so much for a button, isn't it?
the easiest way is to save the code on the server then run it.
Help people,so poeple can help you.
|
|
|
|
|
Yes you are right Ali
something like this will fulfill my need
<asp:button id="Button1" text="Button">
But how can I do it?
|
|
|
|
|
Problem solved, thanks ali
StreamWriter sw;
sw = File.CreateText(Server.MapPath(".") + "//" + "Response.aspx");
string text = "<%@ Page Title=\"Home Page\" Language=\"C#\" MasterPageFile=\"~/Site.master\" AutoEventWireup=\"true\" CodeBehind=\"Default.aspx.cs\" Inherits=\"ASPTest._Default\" ValidateRequest=\"false\" %>";
text += "<asp:Content ID=\"BodyContent\" runat=\"server\" ContentPlaceHolderID=\"MainContent\">";
text += TextBox1.Text;
text += "</asp:Content>";
sw.WriteLine(text);
sw.Close();
Response.Redirect("Response.aspx");
|
|
|
|