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
Related
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
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.
I am using Asp.Net/C# in my application.My current situation is that I am using Jquery tabs on one of my pages , I have tabs in the following order
Personal Details
Additional Details
Submit Data
Show Records
On the tab Show Records I am allowing the user to enter customer name whose records will be displayed in Asp.Net Gridview Control , The GridView is populated with the data on the click of an Asp.Net Button , My issue here is that when the user clicks the button , as it is a server control the page is refreshed and the Personal Details tab is shown and the the user needs to go to the tab Show Records to view the data in the Grid View.It shows the data from the database properly , but It is not what I need.When the button is clicked the tab Show Record should be visible.One solution I researched was to use Html button and call the function from client side.Can you guys suggest me some solution or using the html button is the best solution.
Thanks
append that code to your button click function on server-side
string script = "ShowRecordsTab();"
ScriptManager.RegisterStartupScript(this, this.GetType(), "RecordsTab", script, true);
and add this js code to your view
<script>
function ShowRecordsTab(){
$("li:last").click();
}
</script>
I have a FormView that has two buttons on them. What I need to happen is when the user clicks on the buttons, a popup window is displayed. The data in this window is being pulled from a stored procedure in which I will need to pass variables. Can someone supply code on how to do this?
Create a new page. This is your popup (ie popup). On the your calling page add a hyperlink that calls you popup page but make sure the Target attribute is set to _new which tells the link to open a new browser instance.
Open popup page.
In your pop up page you would then call your ADO.net sql specific code in the Page_Load event.
Are you passing a url encoded variable to this page?
I have a ModalPopupExtender inside an UpdatePanel which opens an input form. The problem is when I click the "Edit" button (which is also inside the UpdatePanel) I want to fill the form with existing values using server side code. But it OnClick method of the button doesn't seem to work.
My question is: How can I make the serverside code run first, than show the edit form?
You need to show the ModalPopupExtender from server side.
First, link the ModalPopupExtender's TargetControlID to a dummy hiddenfield or a button with style="display:none" instead of the "Edit" button. I know it's sound stupid, but it's a know workaround.
Then make sure the asp.net the "Edit" button is set as a asyncpostbacktrigger if children as trigger is set to false.
Also set CausesValidation="false" to avoid the postback to be blocked by unrelated validators on the page.
Finally, At the end of "Edit" button's click event, call ModalPopupExtender.Show() to display the pop up.