I am working on a self design dashboard page. Users drag&drop custom sized boxes in a div element and place some data inside boxes. Once they finish, I would like to save the certain attributes of these boxes in a db, instead of saving whole html code.
<div id="widget0" class="box span2">
<div class="box-header well" style="padding-left: 3px;" data-original-title="">
<div style="float:left">
<i class=" icon-chevron-left"></i>
<i class=" icon-chevron-down"></i>
<i class=" icon-chevron-up"></i>
<i class=" icon-chevron-right"></i>
</div>
<div style="float: right !important; margin-right: -15px;">
<i class="icon-remove"></i>
</div>
</div>
<div class="box-content">
<div id="boxContent0" style="width:100%;height:250px;border-collapse:collapse;" class="ui-droppable">
</div>
</div>
</div>
Above is a sample html code of my box. I'll just save div id, class and contents.
What I've done so far is, I saved required values in an asphiddenfield on a button click event in this format:
"2|widget0,span4,content1,content2|widget1,span3,0,0"
I did this by handling form submit event using jquery, triggered by asp button click. But the db write operations required in my server button click function didn't work. I think this is because I handled the form submit event before btnSaveDashboard_Click(object sender, EventArgs e) function handles and submit the form from jquery..
What I would like to do is, when user click on "save dashboard" button, before redirecting to the dashboard view page, to save these values in my db then redirect.
I just couldn't find a way how to do this with one button click;
get the required html values
save them in a hidden field or somewhere else reachable like viewstate
save these values in my database
I can more provide more details in case needed.
Thanks.
You could use the Button's OnClientClick client side event to populate the HiddenField with the values you need before the Postback occurs.
If you accomplish that, you should have the values you want on the Button's OnClick server side event. You should be able to do whatever you want with them at this point.
Related
On the admin side of my DotNetNuke website, I have two tabs with a few controls. I have also a grid view control on Tab 1 with a few records from the SQL server database i.e. Default Images & Slider Images. Each of the grid view row on Tab 1 also has an Edit button which fills the required textboxes (Image Title, Path, and URL, etc) of Tab 1 with data from that particular row in the code-behind.
When the user clicks on the edit button, an if statement on the code-behind file will check the type of the selected image. If it is a Slider Image, then it's title and URL will be passed to those particular textboxes on Tab 1.
However, if it is a Default Image, then I want to activate Tab 2 and pass the Title, Path, and URL of this default image those specific textboxes on Tab 2.
Is there any way to handle this from c# (code-behind)? Can I mark these tabs something like server controls, so I can easily get them with c# and activate the Tab 2? Any help will highly be appreciated.
Here is an illustration of the Tabs markup I am currently working on.
<div class="dnnForm dnnModuleSettings dnnClear" id="dnnAcProjectsModuleSettings">
<ul class="dnnAdminTabNav dnnClear">
<li>Tab 1</li>
<li>Tab 2</li>
</ul>
<div id="A" class="HomeRoomSlider">
<div class="mspsContent dnnClear">
<fieldset>
//Controls etc
</fieldset>
</div>
</div>
<div id="B" class="HomeRoomSliderDefault">
<div class="mspsContent dnnClear">
<fieldset>
//Controls etc
</fieldset>
</div>
</div>
I'm not am experienced asp.net user so hopefully this is fairly easy as it is in php.
I am trying to receive modified html of a div that is modified by the user of a webpage and save it back to a database.
When I click the save button the old(previous) html data is being displayed not the new html data that I want saved.
html:
<asp:LinkButton ID="saveButton" type="button" CssClass="clickable" runat="server" Text="Save" OnClick="SaveButtonClicked" />
<div id="formContainer" class="form-container" runat="server">
<div class="form-header">Form Title</div>
<ul class="section-sortable"></ul>
<div class="form-footer">
<input type="submit" value="Submit form" />
</div>
</div>
c#
protected void SaveButtonClicked(object sender, EventArgs e)
{
//Returns old html when it should return the new modified html?
Debug.Write(this.formContainer.InnerHtml);
}
The html modification code is not shown here but the html is being modified..
Only solution I found was to listen to both the Click and ClientClick events copy the Inner HTML from the div to a hidden input control and then the data is visible on the click event.
I currently have a page which displays two buttons both when clicked go to different pages and i wanted when the user is done with completing whatever they are doing and save i wanted them routed back to the page they started from (the page displaying the two buttons).
The path where the page with buttons is: .../School/CreatePartySchool...
Fieldset on page that is displayed with the two buttons:
<fieldset>
<legend>Schools</legend>
<div id="address">
<%Html.RenderPartial("SchoolAddress"); %>
</div>
<div id="buttonSaveCancelAlign" style="margin-bottom: 4px">
<a class="glossyBtn" href='<%:Url.Action("Create", "School")%>'>
<img style="vertical-align: middle" alt="" src="<%:Url.Content("~/Content/blueprint/plugins/buttons/icons/add.png")%>" />
<span style="vertical-align: middle">Add School</span> </a>
<input class="glossyBtn" type="submit" name="button" style="vertical-align: middle; padding-right: 13px;" value="Select School"/>
After clicking the Select School .... selecting and saving school
The page returned to is: .../Party/Edit (this page is a level higher than /Schools/CreatePartySchool. I want it to return to /Schools/CreatePartySchool).
your questions do not define the problem..wht u actlly trying to do.as per my knowledge navigation can be handled from code behind,in the onclick event for the button.
I have an application in C# which uses a WebBrowser control.
On one page the user can click a button to process some information and navigate to a new page. The issue is that when the user clicks this button the WebBrowser just seems to stop.
I handle the Navigating, Navigated and DocumentCompleted events in my code and I see the Navigating event but then nothing else.
This is the HTML for the button being clicked:
<div class="right button-wrapper">
<div class="clearfix right">
<span id="nextbutton"
class="button-link button-link btn-reg btn-blue-reg">
<span class="hasHover"><a id="btnPay"
href="javascript:void(0);" class="buttons">Next:Pay and Print</a>
</span>
</span>
</div>
</div>
Buttons on other pages can be clicked with no issues.
I am assuming it has something to do with the href="javascript:void(0);" portion of the HTML but do not know why. In a browser such as IE or Firefox when this button is clicked something like a progress bar appears and say "Processing" for a few seconds and then the next page loads.
EDIT:I should mention that the Navigating handler fires twice and then the page freezes.
This is apparently caused by IE7+'s "Script URL Mitigation" feature and can be fixed for your application by disabling FEATURE_SCRIPTURL_MITIGATION.
i have my login in a fancybox and fancybox div is in a controller. problem is if click the button nothing happens event isnt fired.
this is my controller.ascx
<div id="inline1" style="width:400px;">
<ul class="forms">
<li class="inputfield"><asp:TextBox ID="kullanıcı_adi" runat="server"></asp:TextBox></li>
</ul>
<ul>
<li><asp:TextBox ID="sifre" runat="server"></asp:TextBox></li>
</ul>
<ul>
<li>
<asp:Button ID="Button1" runat="server" Text="Giriş Yap"
onclick="Login_Authenticate" />
<asp:Button ID="Button2" runat="server" Text="Vazgeç"/>
</li>
</ul>
</div>
and this is my cotroller.ascx.cs
protected void Login_Authenticate(object sender, EventArgs e)
{
bool authenticated = AuthenticateMe(kullanıcı_adi.Text, sifre.Text, true);
if (authenticated)
{
FormsAuthentication.RedirectFromLoginPage(kullanıcı_adi.Text, true);
}
}
and this is the default.aspx
<li class="gallery"><a id="various1" href="#inline1">Üye ol/Giriş Yap</a></li>
<div style="display: none;">
<co:c_login ID="id_c_login" runat="server" EnableViewState=true />
</div>
I found the solution. Same question asked before.
Fancybox - ASP.NET button not working Thank you for your answers.
A bit late, but it may help you.
This is because how fancybox works, when fancybox displays the div block, it creates temporary div block with your content and appends it to end of the body tag of the page, hence this generated temporary block is created outside form tag.
In a web page when you postback a page, the control which generates postback event must be within form tag to identify the page postback action.
To resolve this issue you can use a bit of javascript, create another button control but it should not be part of fancybox control, and on submit button within fancybox, fire click event of another created button (which will be inside form tag) with help of javascript.
That should solve your problem, please vote if it answer your question.
We can solve fancybox 2 event not firing issue by using parent property of fancybox.
for example -
$("#buttonClick").fancybox({
parent: "form:first",//Asp.net Button click event not working issue solved by using this statement
......your fancybox config options
});