|
Just check the methods present in Request object like
Request.UserHostAddress i think it will return IP adress of client machine
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi guys,
I have a problem here that I have been unsucessful at solving.
I have a form for user to fill in.
On button click, I perform a series of validations.
Only when the validations pass, I open up a confirm box using javascript.
When the user clicks "OK" I proceed to save the information.
When the user click "Cancel" I refrain from saving the information.
In pseudo code its like this:
btnSave_Click(object sender, EventArgs e)
{
string status= ValidateData();
if(status=="OK")
{
//bring out the confirm box in javascript
ClientScript.RegisterStartupScript(this.GetType(), "ConfirmationPopUp", "getMessage('" + mess.ToString() + "')");
if(userClickOk=="OK")
{
SaveData();
}
}
}
I finally understand that i need a postback from the confirm popup to finally run the SaveData();
So in my java script i try to save the answer in a HiddenField and then on post back check the reply and run SaveData() if the answer is yes.
my Javascript goes like this:
function getMessage(a)
{
var ans;
ans=window.confirm(a);
//ans=;
//alert (ans);
if (ans==true)
{
this.ctl00_ContentPlaceHolder1_HiddenField1.value='Yes';
__doPostBack("","");
}
else
{
this.ctl00_ContentPlaceHolder1_HiddenField1.value='No';
__doPostBack("","");
}
}
However when i try to save the answer in the HiddenField1. I get error that says
this.ctl00_ContentPlaceHolder1_HiddenField1 is null or not an object.
What is wrong? here? I have also tried to save in a session variable which is also not possible?
Please advise how i can achieve this? Is this the right way to do it?
Thanks so much.
|
|
|
|
|
blooper02 wrote: this.ctl00_ContentPlaceHolder1_HiddenField1.value='No';
Hi,
u can not do like this.
Try this.
var MyHDN = Document.GetelementById("Give hidden field's clientID");<br />
MyHDN.value = "No";
-- modified at 0:19 Thursday 22nd November, 2007
Thanks,
Sun Rays
Rate this post if you like answer.
My Articles
|
|
|
|
|
Sun Rays wrote: var MyHDN = Documetn.GetelementByID("Give hidden field's clientID");
MyHDN.value = "No";
wow. That couldnt get more wrong if it tried.
JS is case sensitive. So Documetn [sic] should be document and GetelementByID [sic] would be getElementById .
|
|
|
|
|
It works!
Thanks guys....
My old method this.ctl00_ContentPlaceHolder1_HiddenField1.value='Yes';
works when i created a new webpage but my current project which had a masterpage, it does not work.....
thanks thanks
|
|
|
|
|
You don't have to neccessarily do a PostBack for a confirm message. What is wrong in doing the other way round. prompt a Javascript Confirm Message first and If it's Ok, then do a PostBack for the neccessary server-side validation and saving of Data. If validation fails then Alert a error message otherwise Save the data. I guess this is the correct sequence that will solve the problem and minimize the server round trip as well.
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
Thanks to Sunray and Jamie for the advise
JON,
My server side validation validates to make sure he do not key in rubbish.
I intend to put most of the information that the user key in the confirm box for him to do final check.
When he clicks OK then I save.
What I worry is that the users may claim that if my system so smart to detect their rubbish data, why pop-up and ask them to confirm in the first place?
Do you or others in the developement field face this problem?
Thanks
|
|
|
|
|
blooper02 wrote: Do you or others in the developement field face this problem?
This is not a problem. Actually we are discussing about which is the right way to do such a thing. my point here is it's unnecessary to have 2 server-round trips to save the data.
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
Hi Jon,
I feel that your advice is correct.
Therefore I tried to call the confirm box at OnClientClick.
My Server Validation still runs and triggers fine. But my Validation controls like regular expressions validator did not fire. You know why?
thanks
|
|
|
|
|
Check Whether the CausesValidation Property of the Button Control is set to True
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
Hi Jon,
Yes it is set to true....
But it just does not fire...
Any other possibilities?
|
|
|
|
|
Are you calling any JavaScript function on the Button Click? If yes then it will skip the script validation of the validation Controls. One Alternate to this problem to add the following Code at the end of JavaScript function which you have written.
if (typeof(Page_ClientValidate) == 'function'){ <br />
Page_ClientValidate();<br />
return true;<br />
}
This will call the JavaScript Validation code generated for the Validation Controls.
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
Hi Jon,
I am putting the code as
return confirm('Do you want to confirm this application?');
in the onclientclick property as in the visual studio GUI.
I hope to be able to do it this was as I will be using more of the confirm boxes for my buttons in my gridview.
|
|
|
|
|
Yes Yes Yes Finally....
It should be like this:
<asp:button id="btnUpdate" runat="server" causesvalidation="true" commandname="Update" text="Update" validationgroup="EditValidate" onclientclick="if (!confirm('Update?')) return false">
Solution courtesy of :
http://aspalliance.com/699_Solving_the_Challenges_of_ASPNET_Validation.6
Finally after 2 weeks.....zzzzzzz
|
|
|
|
|
I have web site with Macromedia Flash menu. After clicking on each menu item I would like to display different page, but I want to avoid redrawing flash control after each postback. What is the best way to achieve this ? I dont want to use frames.
|
|
|
|
|
hi friend
I am not sure about this but using AJAX may solve this problem so each time you click menu item the page will not refreshed from the server and you can avoid redrawing flash control.
Prakash Mishra(Banglore,India)
|
|
|
|
|
Yes I was thinking about this as probably the best solution, but I'm not sure how to implement this. I was hoping somebody points me to some good tutorial as I colud not find any.
|
|
|
|
|
You can't find a tutorial on Ajax techniques?
17 million of them here...[^]
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Well all tutorials on Ajax I found show how to get some data asynchronnly. But there is none to show how to asynchonnly redraw whole page except some part (for example my flash menu). I'm not wery strong in ASP.Net, I do mostly Winforms development so I need "good description" .
|
|
|
|
|
hi there
can any one help to create the database driven menus in asp.net
thanks in advance
|
|
|
|
|
which version of ASP.NET are you using?
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
|
|
Hi,
you have to get datafrom database and have to add MenuItem at runtime.
and if Item contains child Items then when creating New MenuItem, you have to add all child items in that MenuItem.
Hope this will help you.
Thanks,
Sun Rays
Rate this post if you like answer.
My Articles
|
|
|
|
|
Hi..
I have a user control . in that i have a text box..
in a web form i am using another text box and button.. along with user control.
now as soon as i type the text in user control text box, and click the button in web form , the text should be displayed in web form text box..
I am able to do it using Session..
Is there any other option of getting done??
Aswini
|
|
|
|