Hi @Donald Symmons,
I modified your code and the code below will work fine for your reference.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
<script>
function Func() {
var positions = JSON.parse(localStorage.positions || "{}");
$(function () {
var d = $("[id*=draggable]").attr("id", function (i) {
return "draggable_" + i
})
$.each(positions, function (id, pos) {
$("#" + id).css(pos)
})
d.draggable({
containment: "#containment-wrapper",
scroll: false,
stop: function (event, ui) {
positions[this.id] = ui.position
localStorage.positions = JSON.stringify(positions)
}
});
$("#clear").click(function () {
window.localStorage.clear();
window.location.reload();
});
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="customer" style="width: 100%; line-height: 1.3; margin-bottom: 3%;">
<div id="draggable1" class="ui-widget-content" style="float: left; text-align: start; margin-bottom: 5%; font-size: 1.6rem;">
<label style="font-size: 10pt; color: #000000; font-weight: 400;">Bill To:</label>
<div style="font-weight: 600;">
<asp:Label ID="nameLbl" runat="server" Font-Size="11pt" Text="Customer Name"></asp:Label>
</div>
<div>
<asp:Label ID="addressLbl" runat="server" Font-Size="10pt" Text="Customer address"></asp:Label>
</div>
<div>
<asp:Label ID="phoneLbl" runat="server" Text="Phone number" Font-Size="10pt"></asp:Label>
</div>
<div>
<asp:Label ID="mailLbl" runat="server" Font-Size="10pt" Text="email address"></asp:Label>
</div>
</div>
<div id="draggable2" class="ui-widget-content" style="float: right; text-align: right; margin-bottom: 5%;">
<asp:Label ID="Label3" runat="server" Font-Size="11pt" Text="#"></asp:Label><asp:Label ID="lblprefix" runat="server" Font-Size="11pt" Text=""></asp:Label>
<div>
<asp:Label ID="issuelbl" runat="server" Font-Size="10pt" Text="Issued date"></asp:Label>
</div>
<div>
<asp:Label ID="datLbl" runat="server" Font-Size="10pt" Text=""></asp:Label>
</div>
<div>
<asp:Label ID="Label15" runat="server" Font-Size="10pt" Text="Due date"></asp:Label>
</div>
<div>
<asp:Label ID="dateLbl" runat="server" Font-Size="10pt" type="date" Text=""></asp:Label>
</div>
</div>
</div>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
//Session["user"] = 6; Test Data
MyDesignFunction();
}
private void MyDesignFunction( )
{
try
{
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
using (SqlCommand cmd = new SqlCommand("SELECT * FROM SavedDesign WHERE Id = @Id", con))
{
cmd.Parameters.AddWithValue("@Id",Convert.ToInt32(Session["user"]));
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "Func()",true);
}
con.Close();
}
}
}
catch (SqlException ex)
{
string msg = "Error:";
msg += ex.Message;
throw new Exception(msg);
}
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.