update status text without page reload - c#

I have a web app! I set a status text for users that is shown below the profile picture of the user. Whenever the user updates the status text, the page reloads on button click, and then the new status appears below the picture. Is there a way to prevent this page reloading and still make the status text changed?
On submit, the new status text is inserted/updated into the database table and then on page load, it is fetched.

You can use Ajax,
Place your Update Button and Status TextBox inside a AjaxUpdatePanel
If it's not possible to add both (Update Button and Status TextBox) to a single AjaxUpdatePanel (as your HTML design), add two different Ajax UpdatePanels (to Update Button and Status TextBox) and call yourstatusupdatepanelname.Update(); from Update Button Click event

you can use jquery ajax to do that and it is easy and will not load your page every time you click a the button:
Asp.net Jquery ajax example

you just asign the status again in button click on success execution of sql statement

I think you need to find out using about ajax , postback for this situation.

You can try with Timer_Tick Event

Related

When I click back button dropdown not going back

When I click back button dropdown not going back. But gridview data going back. Corresponding dropdown not changed properly. I try:
function Back() {
GetPriviousValue();
history.go(-1);
return false;
}
Above this code, dropdown not go back when I click back button, but grid page go back. So I tried cache. That code is:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
But this code produce Document Expired page in firefox. How to get dropdown go back properly when I click back button? Is possible to any jquery?
Well this happens because when you go back the browser displays you the page in the same state that you have left it. And you left it after selecting a value from dropdown.
To mitigate this problem take the help of javascript/jquery. Declare a hiddenfield and set its value in page load with the value of selected dropdown value.
in bodyload event javascript select the dropdown value from hiddenfield.
alernatively you may call form.reset method in body load event.

Postbackurl Vs Response.Redirect (losing data)

I have a button in my aspx page, which in code behind the value of postbackurl gets set. I updated the code to add click event handler and added Response.Redirect code to redirect user to the page once the button is clicked. The only reason i ended up adding click event was because i had to add some extra logic when the button was clicked including redirecting to same url, that was used in postbackurl. The page does get redirected on click however it seems like all the hidden fields from the field gets lost once the form get redirected to the url.
Is there anyway i can submit the form without loosing the hidden data.?
Maybe one way you can solve this problem is to use the server side Transfer() call.
http://msdn.microsoft.com/en-us/library/540y83hx(v=vs.85).aspx
In most cases I've seen what you really want to do is pass the information for the new page using URL parameters. Take all the stuff the new page needs and put it into the url (encrypt if it is security sensitive).
If the only issue you are having is when you want to stay on the same page, this is simple, just have the click event handler return without doing a response.redirect or a transfer.
Post the code if this is not working for you.

Reload a Web Page Using C#

I have a web page that prompts for user input via DropDownLists in some table cells. When a selection is made the selection replaces the DropDownList so that the action can only be performed once. In the case that a change needs to be made I want to be able to click a button that reloads the page from scratch. I have Googled and Googled but I have not managed to find a way to do this.
Any advice is appreciated.
Regards.
Put a link on the page with the text "Reload" and the url the url of the page. It's perfectly valid to have a page with a link to itself.
If you don't like the link idea, use a standard Button and in the click event, use Response.Redirect to redirect to the current page.
You can set an OnClick for your button that resets each DropDownList's SelectedIndex to 0 instead of reloading the page from scratch. Alternatively, you can set a Response.Redirect([the page's url]) into the OnClick as is suggested here.

onclick of any link the web user control is loaded without post back

i have a aspx page and in which\
Add Edit Delete
ABC GRIDVIEW
DEF
GHI
on click of any side link let ABC , DEF etc the Gridview related to that is opened
the gridview is in the Web user control and i have to show the gridview in the Placeholder dynamically.
in this case the whole page is not post back only the page in which the grid view is showing is post back and show the result.
please help and suggest me that how is it possible
It seems you are using dynamically lodaed controls. For events to work, you have to recreate your control on everypostback(OnLoad), if not the event won't be fired.
http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic4
If I understand you correctly, you want to Submit the form in 'GRIDVIEW' by clicking on one of the links on the left?
You can trigger submit events through jQuery as follows:
$("#ABC_link").click(function(event) {
event.preventDefault();
$("#myForm").submit();
});
This will submit the form, but presumably, you'll want to post the form to different locations regarding on which link is clicked?
I would suggest:
$("#ABC_link").click(function(event) {
event.preventDefault();
$("#myForm").get(0).setAttribute('action', 'myCorrectActionValue'); //this works, similar commands tend to fail silently
$("#myForm").submit();
});

Modalpopup not working properly asp.net ajax

I have an updatepanel,a modal popup extender inside that and an image button to open the pop up(it has not any click event). The 'div' for the modal pop up is outside the updatepanel. In the modal pop up the records come in a table with a link in each table row.When the link is clicked,a javascript function causes a hidden control to postback and fetch values from database.First time it is working fine,but next time the image button(TargetControlID for modal pop up extender) does not work and it is causing a postback and loading the page.Help plz...
Thanks in advance.
Mohak
Are you using myLink.ClientID or did you hardcoded the ID of the link in the Javascript function?
The ID of the link is probably changed when doing the first postback, the second time ASP.NET has generated a new ID (not visible in the HTML because of the AJAX-request) for your link and this doesn't match anymore with the ID in your Javascript function.
The solution would be to use myLink.ClientID

Categories

Resources